define(".", [ "static_v4/js/minJS/commonPlug/commonPlug.min", "static_v4/js/plug/mui/mui", "static_v4/js/plug/idupload/mobileFix.mini", "static_v4/js/plug/idupload/exif", "static_v4/js/plug/idupload/lrz", "static_v4/js/mod/submit_giftCard", "static_v4/js/mod/public", "static_v4/js/mod/submit_calcLastPrice", "static_v4/js/mod/submit_sendFriend", "static_v4/js/mod/submit_member", "static_v4/js/mod/submit_coupon", "static_v4/js/mod/submit_coupon_business", "static_v4/js/mod/submit_billing", "static_v4/js/mod/submit_orderGlobal_sea", "static_v4/js/mod/submit_fanXian", "static_v4/js/mod/submit_lipinka", "static_v4/js/mod/submit_pay", "static_v4/js/mod/submit_lpkPay", "static_v4/js/aes", "static_v4/js/mod/submit_order_sea" ], function(require, exports, module) {
    require("static_v4/js/minJS/commonPlug/commonPlug.min");
    // 上传身份证图片插件
    /*require("static_v4/js/minJS/photoClipPlug/photoClipPlug.min");*/
    require("static_v4/js/plug/mui/mui");
    require("static_v4/js/plug/idupload/mobileFix.mini");
    require("static_v4/js/plug/idupload/exif");
    require("static_v4/js/plug/idupload/lrz");
    require("static_v4/js/mod/submit_giftCard");
    require("static_v4/js/mod/submit_sendFriend");
    require("static_v4/js/mod/submit_member");
    require("static_v4/js/mod/submit_coupon");
    require("static_v4/js/mod/submit_coupon_business");
    require("static_v4/js/mod/submit_billing");
    require("static_v4/js/mod/submit_orderGlobal_sea");
    require("static_v4/js/mod/submit_fanXian");
    require("static_v4/js/mod/submit_lipinka");
    require("static_v4/js/mod/submit_calcLastPrice");
    require("static_v4/js/mod/submit_lpkPay");
    require("static_v4/js/mod/submit_pay");
    require("static_v4/js/aes");
    var OIndexSea = require("static_v4/js/mod/submit_order_sea");
    module.exports = {
        init: function(data, name) {
            OIndexSea.init(data, name);
        }
    };
    require.async([ "static_v4/js/plug/mui/mui.zoom", "static_v4/js/plug/mui/mui.viewimage" ], function() {
        var oViewImgBox = $(".js_viewImgBox");
        mui.previewImage(oViewImgBox);
    });
    require.async([ "static_v4/js/mod/iDVerifyPhoto", "static_v4/js/mod/baiduCount" ]);
});
/**
 *  增加或减少(输入) 选择的商品
 */
define("static_v4/js/mod/submit_order_sea", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea", "./submit_coupon" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    var coupon = require("./submit_coupon");
    var oWrap = $(".js_wrap");
    var oMyPayType = $(".js_myPayType");
    // 支付方式选择
    var oSelWeekDay = $(".js_selWeekDay");
    // 日期选择
    var $texRi = $(".addInvoiceMess > .texRi");
    var oBllingText = $(".js_billingText");
    // 发票信息展示
    $("#orderForm").eq(0).find("input[name='prepaidCard']").val("false");
    var lazLoading = new myPub.lazLoadingImg();
    var $submitBtn = $(".js_btnPay");
    // 提交支付按钮
    var oFullGroup = $(".js_fullGroup");
    // 拼单已满提示弹窗
    var oFullGroupCancle = $(".js_fullGroupCancle");
    // 弹窗取消按钮
    var oFullGroupNow = $(".js_fullGroupNow");
    // 弹窗立即拼单按钮
    var oShowNum = $(".js_showNum");
    // 显示手机号码眼睛
    var oPhoneNum = $(".js_phoneNum");
    // 全部手机号码
    var oHidePhoneNUm = $(".js_hidePhoneNUm");
    // 隐藏手机号码
    var nPhoneNum = oPhoneNum.text();
    var nHideNum = nPhoneNum.substr(0, 3) + "****" + nPhoneNum.substr(7, 11);
    module.exports = {
        init: function(data, names) {
            lazLoading.AddLazLoadingImg(oWrap[0]);
            payType.choosePayType();
            if (isJifen == true && canBuy == false && pointCost != null && pointCost != undefined && pointCost != "") {
                myPub.TipLayerLong("抱歉，该商品兑换须" + pointCost + "积分，您的积分暂未达到兑换条件，请继续努力哦！~");
            }
            if (errAddress && errAddress != "") {
                myPub.TipLayerLong(errAddress);
            }
            if (addressOutofProvince && addressOutofProvince != "") {
                myPub.TipLayerLong(addressOutofProvince);
            }
            // 优惠券三期
            if (isJifen == false) {
                coupon.initCoupon();
            }
        }
    };
    // 手机号码隐藏
    oHidePhoneNUm.text(nHideNum);
    oShowNum.on("click", function(e) {
        if ($(this).hasClass("on")) {
            oPhoneNum.hide();
            oHidePhoneNUm.show();
            $(this).removeClass("on icon-eye_look").addClass("icon-eye_close");
        } else {
            oHidePhoneNUm.hide();
            oPhoneNum.show();
            $(this).addClass("on icon-eye_look").removeClass("icon-eye_close");
        }
        e.stopPropagation();
    });
    oMyPayType.hammer().on("tap", function() {
        var index = $(this).index();
        oMyPayType.find(".js_checkBox").removeClass("active").eq(index).addClass("active");
        var payType = oMyPayType.eq(index).attr("data-payType");
        if (oBllingText.hasClass("noInvoiceSupport")) {
            oBllingText.html("添加发票信息");
            oBllingText.removeClass("noInvoiceSupport");
        }
        $texRi.show();
        priceCount.choosePayType(payType);
    });
    // 拼团已满提示弹窗点击取消按钮
    oFullGroupCancle.on("click", function(e) {
        myPub.locationHref("/h/tuangou/goodsDetail/" + goodsSn);
        oFullGroup.hide();
        e.stopPropagation();
    });
    // 拼团已满提示弹窗点击立即拼单按钮
    oFullGroupNow.on("click", function(e) {
        oFullGroup.hide();
        $submitBtn.click();
        e.stopPropagation();
    });
    oSelWeekDay.find("li").hammer().on("tap", function() {
        var index = $(this).index();
        oSelWeekDay.find("li").removeClass("active").eq(index).addClass("active");
    });
    var payType = {
        choosePayType: function() {
            oMyPayType.find(".js_checkBox").removeClass("active").eq(0).addClass("active");
            var payType = oMyPayType.eq(0).attr("data-payType");
            priceCount.choosePayType(payType);
        }
    };
});
define("static_v4/js/mod/submit_giftCard", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    var oUseGiftBtn = $(".js_useGiftBtn");
    var oSetNum = $(".js_setNum");
    var oUseMoneyBtn = $(".js_useMoneyBtn");
    //使用按钮
    var oInputMoney = $(".js_inputMoney");
    //输入框
    var oUseMoneytxt = $(".js_useMoneytxt");
    //最终金额显示位置
    var oSumPrice = oUseGiftBtn.find(".js_sumGiftPrice");
    //剩余礼品卡的金额
    var sBtnName = "去使用";
    /************************************** 使用礼品卡代码 ***********************************************/
    function getMaxCanUseGiftPrice() {
        var sumGift = parseFloat(oSumPrice.text());
        var maxPrice = priceCount.getMaxGiftPrice();
        return Math.min(sumGift, maxPrice);
    }
    //开启和关闭礼品卡使用
    oUseGiftBtn.hammer().on("tap", function() {
        if ($(this).hasClass("on")) {
            $(this).removeClass("on").find(".js_arrow").removeClass("rotate90");
            oSetNum.hide();
        } else {
            $(this).addClass("on").find(".js_arrow").addClass("rotate90");
            oSetNum.show();
        }
    });
    //点击使用按钮执行 .toFixed(2)
    oUseMoneyBtn.hammer().on("tap", function() {
        oInputMoney.blur();
        checkMoneyInput(oInputMoney, function() {
            myPub.TipLayer("只能输入数字或者2位小数");
        }, function() {
            var maxPrice = getMaxCanUseGiftPrice();
            var inputPrice = parseFloat(oInputMoney.val());
            if (inputPrice < 0) {
                oInputMoney.val(0);
                oUseMoneytxt.text(sBtnName).removeClass("color_red");
                myPub.TipLayer("输入的数字或小数必须大于0");
                return;
            }
            if (inputPrice > maxPrice) {
                inputPrice = maxPrice;
            }
            oInputMoney.val(inputPrice);
            oUseMoneytxt.text("-￥" + inputPrice).addClass("color_red");
            oUseGiftBtn.removeClass("on").find(".js_arrow").removeClass("rotate90");
            oSetNum.hide();
            priceCount.useGiftMoney(inputPrice);
        });
    });
    //
    oInputMoney.on("input propertychange", function() {
        var _val = parseFloat(oInputMoney.val());
        var maxPrice = getMaxCanUseGiftPrice();
        if (_val < 0) {
            oInputMoney.val(0);
            oUseMoneytxt.text(sBtnName);
            return;
        }
        if (_val > maxPrice) {
            oInputMoney.val(maxPrice);
        }
        var _reval = oInputMoney.val().replace(/^(\-)*(\d+)\.(\d\d).*$/, "$1$2.$3");
        //只能输入两个小数
        if (oInputMoney.val().length > _reval.length) {
            oInputMoney.val(_reval);
        }
    });
    /*输入框验证*/
    function checkMoneyInput(obj, fn1, fn2) {
        var oIphone = obj.val();
        var reg = /^[0-9]+(.[0-9]{1,2})?$/;
        //验证 正2位小数
        if (!reg.test(oIphone)) {
            if (fn1) fn1();
        } else {
            if (fn2) fn2();
        }
    }
});
define("static_v4/js/mod/submit_sendFriend", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    /***************************    增送他人使用   ******************************/
    var oSwitchBtn = $(".js_switchBtn");
    //滑动按钮框
    var oSendFriendInfo = $(".js_sendFriendInfo");
    //增送他人信息输入框
    var oClearBtn = $(".js_clearBtn");
    //清除按钮
    var oUserName = $(".js_userName");
    //购买者姓名
    var oUserIphone = $(".js_userIphone");
    //购买者电话
    oClearBtn.hide();
    //滑动按钮开启关闭
    oSwitchBtn.hammer().on("tap swipe", function() {
        var index = oSwitchBtn.index($(this));
        if ($(this).hasClass("js_send")) {
            ShowSendFriendInfo(index);
        }
    });
    // 清空输入框
    oClearBtn.hammer().on("tap", function() {
        $(this).parents("li").removeClass("has_error").removeClass("has_success").find(".js_Text").attr("judgeBloor", false);
    });
    //购买者电话检测
    oUserIphone.on("input propertychange", function() {
        oUserIphone.siblings(".js_clearBtn").show();
        myPub.checkMobile(oUserIphone, function() {
            myPub.TipLayer("购买者手机号码不能为空！");
            oUserIphone.parents("li").removeClass("has_error").removeClass("has_success");
            oUserIphone.siblings(".js_clearBtn").hide();
            oUserIphone.attr("judgeBloor", false);
        }, function() {
            oUserIphone.parents("li").addClass("has_error").removeClass("has_success");
            oUserIphone.attr("judgeBloor", false);
        }, function() {
            oUserIphone.parents("li").addClass("has_success").removeClass("has_error");
            oUserIphone.attr("judgeBloor", true);
        });
    });
    //购买者姓名检测
    oUserName.on("input propertychange", function() {
        oUserName.siblings(".js_clearBtn").show();
        checkUserName(oUserName, function() {
            myPub.TipLayer("购买者姓名不能为空！");
            oUserName.parents("li").removeClass("has_error").removeClass("has_success");
            oUserName.siblings(".js_clearBtn").hide();
            oUserName.attr("judgeBloor", false);
        }, function() {
            oUserName.parents("li").addClass("has_error").removeClass("has_success");
            oUserName.attr("judgeBloor", false);
        }, function() {
            oUserName.parents("li").addClass("has_success").removeClass("has_error");
            oUserName.attr("judgeBloor", true);
        });
    });
    //增送他人
    function ShowSendFriendInfo(i) {
        if (oSwitchBtn.eq(i).hasClass("btn_active")) {
            oSwitchBtn.eq(i).removeClass("btn_active");
            oSendFriendInfo.hide();
            $('input[name="isSongLi"]').val(false);
        } else {
            oSwitchBtn.eq(i).addClass("btn_active");
            oSendFriendInfo.show();
            oUserName.val("").parents("li").removeClass("has_error").removeClass("has_success");
            oUserIphone.val("").parents("li").removeClass("has_error").removeClass("has_success");
            oClearBtn.hide();
            $('input[name="isSongLi"]').val(true);
        }
    }
    /*用户名验证*/
    function checkUserName(obj, fn1, fn2, fn3) {
        var _userName = obj.val();
        var reg = /^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5]{1,9}$/;
        //验证用户名
        if (_userName == "") {
            if (fn1) fn1();
        } else if (!reg.test(_userName)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
});
define("static_v4/js/mod/submit_member", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    /***************************    会员积分使用     ******************************/
    var oSwitchBtn = $(".js_switchBtn");
    // 滑动按钮框
    var oIntegralIntroBtn = $(".js_IntegralIntroBtn");
    // 积分规则说明
    var oIntegralIntro = $(".js_IntegralIntro").html();
    // 积分规则说明
    //滑动按钮开启关闭
    oSwitchBtn.hammer().on("tap swipe", function() {
        var index = oSwitchBtn.index($(this));
        if ($(this).hasClass("js_memberPointBtn")) {
            if (!$(this).hasClass("btn_distable")) {
                ShowMemberInfo(index);
            }
        } else if ($(this).hasClass("js_memberBtn")) {
            priceCount.useSFMemberPoint();
        }
    });
    // 积分规则说明
    oIntegralIntroBtn.on("click", function(e) {
        myPub.TipLayerLongClose("积分使用规则", oIntegralIntro, "no", function() {
            $(".layermchild").addClass("titleCenter");
        });
        e.stopPropagation();
    });
    //会员积分
    function ShowMemberInfo(i) {
        if (oSwitchBtn.eq(i).hasClass("btn_active")) {
            //取消
            oSwitchBtn.eq(i).removeClass("btn_active");
        } else {
            //选中
            oSwitchBtn.eq(i).addClass("btn_active");
        }
        priceCount.useMemberPoint();
    }
});
define("static_v4/js/mod/submit_coupon", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    // var couponPlat = require('./submit_coupon_business');
    /***************************    兑换优惠劵     ******************************/
    var oGiftMaTxt = $(".js_giftMaTxt");
    var oGiftMa_TipTxt = $(".js_giftMa_tipTxt");
    var oSubmitGiftMa = $(".js_submitGiftMa");
    var $couponList = $(".js_couponList");
    var oClearBtn = $(".js_clearBtn");
    var offTap = true;
    // 阻止多次点击
    var moreTapOffTime = null;
    // 多次点击定时器
    var Testing = false;
    // 校验按钮是否可点击
    var maxLength = 6;
    // 校验输入框的最长内容
    var errorTip = [ "年丰大当家优惠券使用说明", '<span class="color_red">优惠劵编号错误，请重新输入</span>' ];
    var layerTip = [ "在使用优惠劵之前需要绑定您的手机号", "恭喜您，验证通过!" ];
    var layerStyle_black = "background-color:rgba(0,0,0, 0.6); color:#FFFFFF; border:none; border-radius: 5px; min-width: 50%;";
    var resizeTimer = null;
    // 表单验证
    oGiftMaTxt.on("input propertychange", function() {
        // 通过前端验证 修改提示和改变检测状态
        ValiNumLetter(oGiftMaTxt, function() {
            Testing = false;
            oGiftMa_TipTxt.html(errorTip[1]);
        }, function() {
            Testing = true;
            oGiftMa_TipTxt.html(errorTip[0]);
        });
        // 满足指定数字个数开始验证
        if (oGiftMaTxt.val().length >= maxLength) {
            Testing ? oSubmitGiftMa.addClass("active") : oSubmitGiftMa.removeClass("active");
        } else {
            oSubmitGiftMa.removeClass("active");
        }
    });
    // 提交按钮操作
    oSubmitGiftMa.hammer().on("tap", function() {
        // 变亮状态 还有active
        if ($(this).hasClass("active")) {
            // 防止多次点击
            if (offTap) {
                oGiftMaTxt.blur();
                offTap = false;
                exchangeCouponWithPay();
            }
            clearTimeout(moreTapOffTime);
            moreTapOffTime = setTimeout(function() {
                offTap = true;
            }, 500);
        }
    });
    function exchangeCouponWithPay() {
        var codeSign = oGiftMaTxt.val();
        var allProduct = priceCount.calAllProduct();
        G_JSON_POST("/coupon/exchangeCoupon", {
            codeSign: codeSign,
            productsJson: JSON.stringify(allProduct)
        }, function(data) {
            if (data.status != "success") {
                myPub.TipLayer(data.message);
            } else {
                var couponArray = data.obj;
                for (var i = 0; i < couponArray.length; i++) {
                    var coupon = couponArray[i];
                    addCanUseCoupon(coupon);
                    // couponPlat.GetGoodsList();
                    myPub.TipLayer("兑换成功");
                }
                oGiftMaTxt.val("");
            }
        });
    }
    exports.exchangeCouponWithPay = exchangeCouponWithPay;
    function addCanUseCoupon(coupon) {
        var benginDate = new Date(coupon.beginDate);
        var endDate = new Date(coupon.endDate);
        var couponHtml = [ '<div class="coupon platCoupon orderCoupon js_coupon" ' + '  data-couponId="' + coupon.userCouponId + '"' + '  data-supplierId="' + coupon.supplierId + '"' + '  data-limitType="' + coupon.limitType + '"' + '  data-supplierSet="' + coupon.supplierSet + '"' + '  data-categorySet="' + coupon.categorySet + '"' + '  data-goodsSet="' + coupon.goodsSet + '">' + '      <div class="couponBox" >' + '          <div class="couponInfo HBox">' + '              <div class="couponInfoLeft HBox BoxCenter">' + '                 <div class="couponPrice">' + "                      <em>￥</em>" + '                      <span class="js_costPrice">' + coupon.costPrice + "</span>" + '                      <p>满<i class="js_threshold">' + coupon.needPrice + "</i>元可用</p>" + "                  </div>" + "              </div>" + '              <div class="couponInfoCenter Bflex1 height_100">' + '                  <div class="couponUseType">' + '                      <h5 class="singleLine" >' + coupon.couponName + "</h5>" + '                      <div class="tip_use" >' + "                          <p>" + coupon.limitDescribe + "</p>" + "                      </div>" + '                      <div class="tip_useLimt Bflex1">' + "                          <p>" + myPub.FormatDateTime(benginDate, "minDay", ".") + " - " + myPub.FormatDateTime(endDate, "minDay", ".") + "</p>" + "                      </div>" + "                  </div>" + "              </div>" + '              <div class="couponInfoRight HBox BoxCenter">' + '                  <div class="useThisCoupon">' + '                      <div class="useThisCouponBtn HBox BoxCenter">' + '                          <p class="activeCheck">' + '                              <span class="icon-check"></span>' + "                          </p>" + "                      </div>" + "                  </div>" + "              </div>" + "          </div>" + "      </div>" + '      <div class="gapBox gapBox_right">' + '          <span class="gap gap_top"></span>' + '          <span class="gap_line"></span>' + '          <span class="gap gap_bot"></span>' + "      </div>" + "  </div>" ].join("");
        $couponList.append(couponHtml);
    }
    // 清空按钮操作
    oClearBtn.hammer().on("tap", function() {
        oGiftMaTxt.val("");
        oGiftMa_TipTxt.html(errorTip[0]);
        oSubmitGiftMa.removeClass("active");
    });
    /* 数字字母验证 */
    function ValiNumLetter(obj, fn1, fn2) {
        var reg = new RegExp("^[a-zA-Z0-9]*$");
        if (!reg.test(obj.val())) {
            if (fn1) fn1();
        } else {
            if (fn2) fn2();
        }
    }
    /***************************    使用优惠劵     ******************************/
    var oShadow = $(".js_shadow");
    // 阴影
    var oCouponSeletSide = $(".js_couponSeletSide");
    // 优惠劵弹框
    var oUseCouponSubOrd = $(".js_useCouponSubOrd");
    // 优惠劵列表展示按钮
    var oSubOrdCoupon = $(".js_subOrdCoupon");
    // 提交订单 优惠劵框
    var oCouponBtn_close = $(".js_couponBtn_close");
    // 优惠劵关闭
    var bSideOff = true;
    var moveHeight = oCouponSeletSide.outerHeight(true);
    // 优惠劵弹框高度
    oCouponSeletSide.css({
        bottom: -moveHeight
    });
    // 提交订单选 优惠劵
    oUseCouponSubOrd.hammer().on("tap", function() {
        if ($(this).find(".couponOff").length > 0) {
            return;
        }
        if (typeof bindMobile != "undefined" && bindMobile == "bindMobile") {
            // 没有绑定的话 弹出 绑定手机弹框
            myPub.askLayer(layerTip[0], function() {
                // 立即绑定
                if (typeof backHref != "undefined") {
                    window.location.href = "/h/login/bindMobile?backHref=" + backHref;
                } else {
                    window.location.href = "/h/login/bindMobile";
                }
                myPub.LayerCloseAll();
            }, function() {
                // 取消
                myPub.LayerCloseAll();
            }, "no", null, [ "立即绑定", "取消" ]);
            return;
        }
        if (!bSideOff) return;
        bSideOff = false;
        oSubOrdCoupon.show().stop().animate({
            bottom: 0
        }, 300, function() {
            oShadow.show();
            bSideOff = true;
        });
        myPub.HamstopPropaga();
    });
    // 优惠劵使用选择
    $couponList.hammer().on("tap", function(e) {
        var _tag = e.gesture.target;
        var $target;
        if ($(_tag).parents(".js_coupon").length > 0) {
            $target = $(_tag).parents(".js_coupon");
        } else {
            return;
        }
        if ($target.hasClass("active")) {
            // 取消使用优惠券
            oSubOrdCoupon.find(".js_coupon").removeClass("active");
            var overMid = $(".js_showBusCoup ");
            if (overMid.length > 0) {
                $(".js_toUseCouponNull").hide();
                $(".js_toUseCouponHave").show().find(".js_verMid").text(overMid.length + "张可用");
                $(".js_showUseCouponPrice").hide().find(".js_showPrice").text("0.0");
            }
            // $('.js_toUseCoupon').show();
            priceCount.useCouponPrice(0, 0);
        } else {
            // 使用优惠券
            oSubOrdCoupon.find(".js_coupon").removeClass("active");
            $target.addClass("active");
            //设置选中
            var couponPrice = $target.find(".js_costPrice").text();
            // 获取优惠卷金额
            var couponId = parseInt($target.attr("data-couponId"));
            // 获取优惠卷id
            $(".js_showUseCouponPrice").show().find(".js_showPrice").text(couponPrice);
            // 将金额放进优惠卷位置
            // $('.js_toUseCoupon').hide();// 隐藏对应的
            $(".js_toUseCouponNull").hide();
            $(".js_toUseCouponHave").hide();
            priceCount.useCouponPrice(parseFloat(couponPrice), couponId);
        }
        myPub.HamstopPropaga();
    });
    // 默认选中最大额的优惠券并给显示的优惠券添加类名标识
    function couponchooseShow(arr, fn1) {
        // console.log('arr',arr)
        if (oUseCouponSubOrd.length > 0) {
            var w = $("div.js_couponList > div.js_coupon");
            if (w.length > 0) {
                if (arr.length > 0) {
                    for (var o = 0; o < arr.length; o++) {
                        var arrDepare = arr[o];
                        for (var j = 0; j < arrDepare.length; j++) {
                            var nCompare = arrDepare[j].oldPrice * 1 - arrDepare[j].BusConPrice * 1;
                            if (nCompare >= arrDepare[j].limitPlatPrice * 1) {
                                IsShow(w, arrDepare[j].couponId, "add");
                            } else {
                                IsShow(w, arrDepare[j].couponId, "remove");
                            }
                        }
                    }
                }
                initCoupon();
            }
        }
        if (fn1) fn1();
    }
    exports.couponchooseShow = couponchooseShow;
    function initCoupon() {
        var w = $("div.js_couponList > div.js_showBusCoup");
        if (w.length == 0) {
            $(".js_toUseCouponNull").show();
            $(".js_toUseCouponHave").hide();
            $(".js_showUseCouponPrice").hide();
            priceCount.useCouponPrice(parseFloat(0), 0);
        }
        if (w.length > 0) {
            var max = w.eq(0).find(".js_costPrice").text() * 1;
            var index = 0;
            for (var i = 1; i < w.length; i++) {
                if (w.eq(i).find(".js_costPrice").text() * 1 > max) {
                    max = w.eq(i).find(".js_costPrice").text();
                    index = i;
                }
            }
            w = w.eq(index);
            selected(w);
        }
    }
    exports.initCoupon = initCoupon;
    function selected(w) {
        w.siblings().removeClass("active");
        w.addClass("active");
        var couponPrice = w.find(".js_costPrice").text();
        var couponId = parseInt(w.attr("data-couponId"));
        // $('.js_showUseCouponPrice').show().find('.js_showPrice').text(couponPrice);
        // $('.js_toUseCoupon').hide();
        $(".js_showUseCouponPrice").show().find(".js_showPrice").text(couponPrice);
        $(".js_toUseCouponNull").hide();
        $(".js_toUseCouponHave").hide();
        priceCount.useCouponPrice(parseFloat(couponPrice), couponId);
    }
    function IsShow(duty, upon, type) {
        for (var i = 0; i < duty.length; i++) {
            var nPlatCouponId = duty.eq(i).attr("data-couponid") * 1;
            if (upon == nPlatCouponId) {
                if (type == "remove") {
                    duty.eq(i).removeClass("js_showBusCoup");
                } else if (type == "add") {
                    duty.eq(i).addClass("js_showBusCoup");
                }
            }
            if (duty.eq(i).hasClass("js_showBusCoup")) {
                duty.eq(i).show();
            } else {
                duty.eq(i).hide();
            }
        }
    }
    // 阴影关闭
    oShadow.hammer().on("tap", function(e) {
        //隐藏服务
        oSubOrdCoupon.stop().animate({
            bottom: -moveHeight
        }, 300, function() {
            oSubOrdCoupon.hide();
            oShadow.hide();
            bSideOff = true;
        });
        e.stopPropagation();
    });
    // 不使用优惠劵
    oCouponBtn_close.hammer().on("tap", function(e) {
        // 隐藏弹框
        oSubOrdCoupon.stop().animate({
            bottom: -moveHeight
        }, 300, function() {
            oSubOrdCoupon.hide();
            oShadow.hide();
            bSideOff = true;
        });
        e.stopPropagation();
    });
});
define("static_v4/js/mod/submit_coupon_business", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea", "./submit_coupon" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    var couponPrice = require("./submit_coupon");
    /***************************    商家优惠   ******************************/
    var oWrap = $(".js_wrap");
    var oBusiShadow = $(".js_busiShadow");
    // 阴影
    var oCouponSeletSideBus = $(".js_couponSeletSideBus");
    // 商家优惠弹框
    var oUseCouponBus = $(".js_useCouponBus");
    // 商家优惠操作入口
    var oCouponBusBtn_close = $(".js_couponBusBtn_close");
    // 优惠劵关闭
    var oSubOrdCouponBus = $(".js_subOrdCouponBus");
    // 提交订单 商家优惠框 (单独用)
    var oGoodsListBox = $(".js_carListBox");
    var oGoodsList = $(".js_goodsList");
    var oCarListArea = $(".js_carListArea");
    var oBusinessPay = $(".js_businessPay");
    var bSideOff = true;
    var platformBuisneCouponId = [];
    var couponPriceArr = [];
    var couponbusineId = 0;
    var couponbusinePrice = 0;
    var arrbusineArr = [];
    var ide = null;
    var buyProductList = [];
    //
    var subtotalList = [];
    // 全部商品详情ID
    var $sfMember = $(".jsSFMember");
    // 顺丰会员
    var sfMemberCutPrice = 0;
    // 顺丰会员的 只支持商详页跳确认订单页购买
    if ($sfMember.length > 0) {
        var cutPrice = parseFloat($sfMember.attr("data-cutPrice"));
        if ($sfMember.find(".js_memberBtn").hasClass("btn_active")) {
            sfMemberCutPrice = cutPrice;
        } else {
            sfMemberCutPrice = 0;
        }
    }
    var coupon = {
        allArr: [],
        // 平台通用类型优惠券
        storeArr: [],
        // 指定商家类型优惠券
        cateArr: [],
        // 指定分类优惠券
        goodsIdArr: [],
        // 指定商品优惠券
        storeDisableArr: [],
        // 指定商家不可用
        cateDisableArr: [],
        // 指定分类不可用
        goodsDisableArr: [],
        // 指定商品不可用
        tagArr: [],
        // 指定标签能用
        // 把优惠券分类
        CouponMsg: function() {
            var _this = this;
            var oCouponEl = $(".js_coupon");
            // console.log(oCouponEl);
            var couponTypeArr = [];
            for (var i = 0; i < oCouponEl.length; i++) {
                couponTypeArr.push(oCouponEl.eq(i).attr("data-limitType"));
            }
            for (var j = 0; j < couponTypeArr.length; j++) {
                var obj = {};
                var oCouponTy = oCouponEl.eq(j);
                var nSwitch = couponTypeArr[j] * 1;
                switch (nSwitch) {
                  case 0:
                    obj.limitType = 0;
                    // 优惠券类型
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPricePrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.allArr.push(obj);
                    break;

                  case 1:
                    obj.limitType = 1;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-supplierSet");
                    // 对应的商家Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.storeArr.push(obj);
                    break;

                  case 2:
                    obj.limitType = 2;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-categorySet");
                    // 对应的分类Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.cateArr.push(obj);
                    break;

                  case 3:
                    obj.limitType = 3;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-goodsSet");
                    // 对应的商品Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.goodsIdArr.push(obj);
                    break;

                  case 4:
                    obj.limitType = 4;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-goodsSet");
                    // 对应的商品Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.goodsDisableArr.push(obj);
                    break;

                  case 5:
                    obj.limitType = 5;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-supplierSet");
                    // 对应的商家Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.storeDisableArr.push(obj);
                    break;

                  case 6:
                    obj.limitType = 6;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-categorySet");
                    // 对应的分类Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.cateDisableArr.push(obj);
                    break;

                  case 7:
                    obj.limitType = 7;
                    // 优惠券类型
                    obj.goodsArr = oCouponTy.attr("data-goodsLabel");
                    // 对应的分类Id
                    obj.couponId = oCouponTy.attr("data-couponId");
                    // 优惠券Id
                    obj.limitPlatPrice = oCouponTy.find(".js_threshold").text() * 1;
                    // 优惠券使用限制金额
                    obj.usePlatPrice = oCouponTy.find(".js_costPrice").text() * 1;
                    // 优惠券金额
                    _this.tagArr.push(obj);
                    break;

                  default:
                    break;
                }
            }
        },
        // 算出确认订单页面适用各个优惠券的原价
        CostPrice: function() {
            var _this = this;
            _this.allArr = [];
            _this.storeArr = [];
            _this.cateArr = [];
            _this.goodsIdArr = [];
            _this.storeDisableArr = [];
            _this.cateDisableArr = [];
            _this.goodsDisableArr = [];
            _this.tagArr = [];
            _this.CouponMsg();
            /*console.log('allArr',_this.allArr);
            console.log('storeArr',_this.storeArr);
            console.log('cateArr',_this.cateArr);
            console.log('goodsIdArr',_this.goodsIdArr);
            console.log('storeDisableArr',_this.storeDisableArr);
            console.log('cateDisableArr',_this.cateDisableArr);
            console.log('goodsDisableArr',_this.goodsDisableArr);
            console.log('tagArr',_this.tagArr);*/
            _this.CostMethods(_this.allArr, "", false);
            _this.CostMethods(_this.storeArr, "supplierId", false);
            _this.CostMethods(_this.cateArr, "categoryId", false);
            _this.CostMethods(_this.goodsIdArr, "goodsId", false);
            _this.CostMethods(_this.storeDisableArr, "supplierId", true);
            _this.CostMethods(_this.cateDisableArr, "categoryId", true);
            _this.CostMethods(_this.goodsDisableArr, "goodsId", true);
            _this.CostArrMethods(_this.tagArr);
        },
        // 计算标签优惠券
        CostArrMethods: function(arr) {
            var _this = this;
            for (var n = 0; n < arr.length; n++) {
                var couponLabel = arr[n].goodsArr.replace("[", "").replace("]", "").replace(/\s/g, "");
                var nPriceTol = 0;
                var nBusPriceTol = 0;
                if (couponLabel.indexOf(",") > -1) {
                    couponLabel = couponLabel.split(",");
                } else {
                    if (couponLabel != undefined && couponLabel.length > 0) {
                        couponLabel = [ couponLabel ];
                    } else {
                        couponLabel = [];
                    }
                }
                for (var i = 0; i < subtotalList.length; i++) {
                    var labelArr = subtotalList[i][0].goodsLabelId.replace("[", "").replace("]", "").replace(/\s/g, "");
                    var nPriceLim = 0;
                    var nbusLim = 0;
                    var canUse = [];
                    if (labelArr.indexOf(",") > -1) {
                        labelArr = labelArr.split(",");
                    } else {
                        if (labelArr != undefined && labelArr.length > 0) {
                            labelArr = [ labelArr ];
                        } else {
                            labelArr = [];
                        }
                    }
                    canUse = couponLabel.filter(function(v) {
                        return labelArr.indexOf(v) !== -1;
                    });
                    if (canUse.length > 0) {
                        nPriceLim = subtotalList[i][0].quantity * 1 * subtotalList[i][0].price * 1;
                        nbusLim = subtotalList[i][0].busPrice * 1;
                    }
                    nPriceTol += nPriceLim;
                    nBusPriceTol += nbusLim;
                }
                arr[n].oldPrice = nPriceTol - sfMemberCutPrice;
                // 适用该优惠券的所有商品价格
                arr[n].BusConPrice = nBusPriceTol;
            }
        },
        // 计算其他类型优惠券
        CostMethods: function(arr, pe, isDisable) {
            var _this = this;
            for (var i = 0; i < arr.length; i++) {
                if (pe == "") {
                    var nPrice = 0;
                    var nBuslimPrice = 0;
                    for (var b = 0; b < subtotalList.length; b++) {
                        var nAllPrice = 0;
                        var nAllBusPrice = 0;
                        nAllPrice = subtotalList[b][0].quantity * 1 * subtotalList[b][0].price * 1;
                        nAllBusPrice = subtotalList[b][0].busPrice * 1;
                        nPrice += nAllPrice;
                        // 适用该优惠券的所有商品价格
                        nBuslimPrice += nAllBusPrice;
                    }
                    arr[i].oldPrice = nPrice - sfMemberCutPrice;
                    arr[i].BusConPrice = nBuslimPrice;
                } else {
                    var nArr = arr[i].goodsArr.replace("[", "").replace("]", "");
                    var goodsIdStore = [];
                    var nPriceTol = 0;
                    var nBusPriceTol = 0;
                    var disArr = [];
                    // 放指定不可用类型的优惠券 的可用商品
                    if (nArr.indexOf(",") > -1) {
                        goodsIdStore = nArr.split(",");
                    } else {
                        goodsIdStore = [ nArr ];
                    }
                    for (var j = 0; j < goodsIdStore.length; j++) {
                        for (var n = 0; n < subtotalList.length; n++) {
                            var nPriceLim = 0;
                            var nbusLim = 0;
                            var type = null;
                            switch (pe) {
                              case "supplierId":
                                type = subtotalList[n][0].supplierId * 1;
                                break;

                              case "categoryId":
                                type = subtotalList[n][0].categoryId * 1;
                                break;

                              case "goodsId":
                                type = subtotalList[n][0].goodsId * 1;
                                break;

                              case "supplierDisableId":
                                type = subtotalList[n][0].supplierId * 1;
                                break;

                              case "categoryDisableId":
                                type = subtotalList[n][0].categoryId * 1;
                                break;

                              case "goodsDisableId":
                                type = subtotalList[n][0].goodsId * 1;
                                break;

                              default:
                                break;
                            }
                            if (isDisable) {
                                if (goodsIdStore[j] * 1 !== type) {
                                    if (disArr.indexOf(subtotalList[n][0]) == -1) {
                                        disArr.push(subtotalList[n][0]);
                                        nPriceLim = subtotalList[n][0].quantity * 1 * subtotalList[n][0].price * 1;
                                        nbusLim = subtotalList[n][0].busPrice * 1;
                                    }
                                }
                            } else {
                                if (goodsIdStore[j] * 1 === type) {
                                    nPriceLim = subtotalList[n][0].quantity * 1 * subtotalList[n][0].price * 1;
                                    nbusLim = subtotalList[n][0].busPrice * 1;
                                }
                            }
                            nPriceTol += nPriceLim;
                            nBusPriceTol += nbusLim;
                        }
                    }
                    arr[i].oldPrice = nPriceTol - sfMemberCutPrice;
                    // 适用该优惠券的所有商品价格
                    arr[i].BusConPrice = nBusPriceTol;
                }
            }
        },
        // 商家优惠劵分类判断
        priceScale: function(storeCoupons) {
            var _this = this;
            // 使用商家优惠劵
            if (storeCoupons) {
                // [28625, 28626, 28632]
                switch (storeCoupons.couponLimitType) {
                  // 全场通用
                    case 0:
                    // console.log('couponLimitType=0',storeCoupons)
                    _this.setGoodsListInfo(storeCoupons);
                    break;

                  // 指定商品
                    case 3:
                    // console.log('couponLimitType=3',storeCoupons)
                    _this.setGoodsListInfo(storeCoupons);
                    break;

                  // 指定不可使用商品
                    case 4:
                    // console.log('couponLimitType=4',storeCoupons)
                    _this.setGoodsListInfo(storeCoupons, "reverse");
                    break;

                  default:
                    break;
                }
                _this.setBusPrice();
            } else {}
        },
        // 获取相同id的商家产品list
        setGoodsListInfo: function(data, type) {
            var _this = this;
            var arrPrice = [];
            var $tarId = [];
            var sum = 0;
            var _reducePrice = [];
            for (var i = 0; i < subtotalList.length; i++) {
                var _List = subtotalList[i][0];
                // 匹配商家
                if (data.supplierId == _List.supplierId) {
                    _this.setOfferPrice(data, _List, type, function(price, elemt) {
                        arrPrice.push(price);
                        $tarId.push(elemt);
                    });
                }
            }
            sum = _this.arrSum(arrPrice);
            // console.log('sum', sum)
            for (var n = 0; n < arrPrice.length; n++) {
                // console.log(arrPrice[n]/sum * data.couponPrice)
                // console.log(( Math.round( arrPrice[n]/sum * data.couponPrice * 100 )/100 ).toFixed(2))
                var reducePrice = (Math.round(arrPrice[n] / sum * data.couponPrice * 100) / 100).toFixed(2);
                _reducePrice.push(reducePrice);
                // 最有上面循环完成可执行
                if (n == arrPrice.length - 1) {
                    oCarListArea.each(function(k) {
                        if ($(this).attr("data-goodsid") * 1 == $tarId[k]) {
                            // 如果后面的价格大于优惠劵价格
                            if (_this.arrSum(_reducePrice) > data.couponPrice) {
                                // oCarListArea.find('.js_goodsPrice').eq(oCarListArea.length-1).attr('data-reducePrice', _reducePrice[n])
                                oCarListArea.find(".js_goodsPrice").eq(oCarListArea.length - 1).attr("data-reducePrice", data.couponPrice);
                            } else {
                                // console.log(k,$tarId )
                                // 设置最后减过优惠的价格
                                $(this).find(".js_goodsPrice").attr("data-reducePrice", _reducePrice[k]);
                            }
                        }
                    });
                }
            }
        },
        setOfferPrice: function(arrlist, val, type, fn) {
            var arrCouponGoodsSet = arrlist.couponGoodsSet;
            var valGoodsId = val.goodsId * 1;
            var _count = 0;
            // console.log('arrCouponGoodsSet', arrCouponGoodsSet)
            // 全场通用
            if (arrCouponGoodsSet == "") {
                if (fn) fn(val.price * val.quantity, valGoodsId);
            } else {
                // 指定商品可用
                if (!type) {
                    for (var i = 0; i < arrCouponGoodsSet.length; i++) {
                        if (arrCouponGoodsSet[i] * 1 == valGoodsId) {
                            // console.log(val)
                            if (fn) fn(val.price * val.quantity, valGoodsId);
                        }
                    }
                } else {
                    for (var i = 0; i < arrCouponGoodsSet.length; i++) {
                        if (arrCouponGoodsSet[i] * 1 != valGoodsId) {
                            // console.log(val)
                            _count++;
                        }
                    }
                    // 只记录商品统计次数到最大值 才能进行回调操作
                    if (_count == arrCouponGoodsSet.length) {
                        if (fn) fn(val.price * val.quantity, valGoodsId);
                    }
                }
            }
        },
        // 数组求和
        arrSum: function(arr) {
            var s = 0;
            if (arr.length == 0) {
                return 0;
            } else if (arr.length == 1) {
                return arr[0];
            } else {
                for (var i = 0; i < arr.length; i++) {
                    s += arr[i] * 1;
                }
                return s;
            }
        },
        // 设置优惠劵
        initCoupons: function() {
            var _this = this;
            // console.log('coupon_business', _this.storeDisableArr);
            // console.log('coupon_business', _this.cateDisableArr);
            // console.log('coupon_business', _this.goodsDisableArr);
            _this.CostPrice();
            priceCount.initAllPrice();
            couponPrice.couponchooseShow([ _this.cateArr, _this.storeArr, _this.allArr, _this.tagArr, _this.goodsIdArr, _this.storeDisableArr, _this.cateDisableArr, _this.goodsDisableArr ], function() {
                priceCount.useBuisneCouponPrice(platformBuisneCouponId, couponPriceArr);
            });
        },
        // 设置商家优惠券等比例减后价格
        setBusPrice: function() {
            var nReduceprice = 0;
            for (var i = 0; i < subtotalList.length; i++) {
                nReduceprice = oGoodsList.find(".js_goodsPrice").eq(i).attr("data-reduceprice") * 1;
                subtotalList[i][0].busPrice = nReduceprice;
            }
        }
    };
    exports.coupon = coupon;
    oUseCouponBus.each(function() {
        var _this = $(this);
        var moveHeight = _this.siblings(".js_couponSeletSideBus").outerHeight(true);
        //商家优惠高度
        _this.siblings(".js_couponSeletSideBus").css({
            bottom: -moveHeight
        });
        // 商家优惠使用 显示优惠券
        _this.hammer().on("tap", function() {
            if (!bSideOff) return;
            bSideOff = false;
            oWrap.addClass("businesWrap");
            _this.siblings(".js_subOrdCouponBus").show().stop().animate({
                bottom: 0
            }, 300, function() {
                _this.siblings(".js_busiShadow").show();
                bSideOff = true;
            });
            myPub.HamstopPropaga();
        });
        _this.siblings(".js_busiShadow").hammer().on("tap", function(e) {
            // 点击阴影隐藏优惠券
            _this.siblings(".js_subOrdCouponBus").stop().animate({
                bottom: -moveHeight
            }, 300, function() {
                oWrap.removeClass("businesWrap");
                _this.siblings(".js_subOrdCouponBus").hide();
                _this.siblings(".js_busiShadow").hide();
                bSideOff = true;
            });
            e.stopPropagation();
        });
        _this.siblings(".js_subOrdCouponBus").find(".js_couponBusBtn_close").hammer().on("tap", function(e) {
            // 点击确定按钮隐藏优惠券
            $(this).parents(".js_couponSeletSideBus").stop().animate({
                bottom: -moveHeight
            }, 300, function() {
                oWrap.removeClass("businesWrap");
                $(this).hide();
                $(this).siblings(".js_busiShadow").hide();
                bSideOff = true;
            });
            // myPub.HamstopPropaga();
            e.stopPropagation();
        });
    });
    // 获取商品数据
    GetGoodsList();
    function GetGoodsList() {
        oGoodsList.find("li").each(function() {
            var $goodsLi = $(this);
            var supplierId = $goodsLi.parents(".js_carListBox").find(".js_storeOwner").attr("data-supplierId") * 1;
            var $goodsArea = $goodsLi.find(".js_carListArea");
            var goodsId = parseInt($goodsArea.attr("data-goodsId"));
            var productId = parseInt($goodsArea.attr("data-productId"));
            var goodsFinalPrice = parseFloat($goodsArea.find(".js_goodsPrice").attr("data-finalPrice"));
            var goodsCategoryId = parseFloat($goodsArea.attr("data-categoryId"));
            var goodsLabelId = $goodsArea.attr("data-goodsLabel");
            var quantity = parseInt($goodsArea.find(".js_quantity").attr("data-quantity"));
            $goodsLi.find(".js_goodsPrice").attr("data-reducePrice", 0);
            var busPrice = parseFloat($goodsArea.find(".js_goodsPrice").attr("data-reduceprice"));
            var buyProduct = {
                supplierId: supplierId,
                goodsId: goodsId,
                productId: productId,
                quantity: quantity,
                price: goodsFinalPrice,
                categoryId: goodsCategoryId,
                busPrice: busPrice,
                goodsLabelId: goodsLabelId
            };
            buyProductList.push(buyProduct);
            subtotalList.push(buyProductList);
            buyProductList = [];
        });
    }
    exports.GetGoodsList = GetGoodsList;
    // console.log(subtotalList);
    busChooseOptimal();
    // 商家优惠券 开始最优选择
    function busChooseOptimal() {
        var nSFMemberJifen = 0;
        var nSFMemberOff = false;
        couponPriceArr = [];
        platformBuisneCouponId = [];
        if ($sfMember.length > 0) {
            var oGoodsPrice = $(".js_goodsPrice").attr("data-finalprice") * 1 * $(".js_quantity").attr("data-quantity");
            nSFMemberJifen = oGoodsPrice - sfMemberCutPrice;
        }
        oGoodsListBox.each(function(n, el) {
            // 商家ID
            var nSupplierId = $(this).find(".js_storeOwner").attr("data-supplierId") * 1;
            // 商家券使用限制额度
            var oGoodsBusLimit = $(el).find(".js_busConponLimit");
            // 默认选中最大的值的优惠券
            var w = $(el).find(".js_busConpon");
            // 商家优惠劵 id， 优惠劵部分数据
            var couponId, jsonStoreCoupon, couponGoodsSet;
            var couponPrice = 0;
            var oBusinessPay = $(el).find(".js_businessPay");
            if (w.length > 0) {
                var max = w.eq(0).find(".js_busniConponPrice").text() * 1;
                var index = 0;
                for (var i = 0; i < w.length; i++) {
                    if ($sfMember.length > 0) {
                        if (nSFMemberJifen - oGoodsBusLimit.eq(i).text() * 1 < 0) {
                            oBusinessPay.text("不使用");
                            oBusinessPay.attr("data-businePrice", 0);
                            oBusinessPay.addClass("busineCouDollor");
                            w.eq(i).parent("li").addClass("hideBusSFCou");
                            index = null;
                        } else {
                            if (w.eq(i).find(".js_busniConponPrice").text() * 1 > max) {
                                max = w.eq(i).find(".js_busniConponPrice").text();
                                index = i;
                            }
                        }
                    } else {
                        if (w.eq(i).find(".js_busniConponPrice").text() * 1 > max) {
                            max = w.eq(i).find(".js_busniConponPrice").text();
                            index = i;
                        }
                    }
                }
                if (index != null) {
                    nSFMemberOff = true;
                    w = w.eq(index);
                    couponId = w.attr("couponBuisId");
                    couponPrice = w.find(".js_busniConponPrice").text();
                    if (w.attr("data-goodsSet") !== undefined) {
                        // 商家id supplierId, conpon.find('.js_goodsPrice').attr('data-reducePrice', 0);
                        // 商家优惠劵 couponId，
                        // 指定商品数组 couponGoodsSet，
                        // 设置条件 couponLimitType，
                        // 优惠劵面值价格 couponPrice
                        var _arr = [];
                        couponGoodsSet = w.attr("data-goodsSet").replace(/\s*/g, "").replace("[", "").replace("]", "");
                        couponGoodsSet.indexOf(",") > -1 ? _arr = couponGoodsSet.split(",") : _arr.push(couponGoodsSet);
                        jsonStoreCoupon = {
                            supplierId: nSupplierId,
                            couponId: couponId * 1,
                            couponGoodsSet: _arr,
                            couponLimitType: w.attr("data-limitType") * 1,
                            couponPrice: couponPrice * 1
                        };
                        coupon.priceScale(jsonStoreCoupon);
                    }
                }
            } else {
                nSFMemberOff = true;
                couponId = 0;
                couponPrice = 0;
            }
            if (nSFMemberOff) {
                w.addClass("active");
                oBusinessPay.text("-￥" + couponPrice);
                oBusinessPay.attr("data-businePrice", couponPrice);
                oBusinessPay.removeClass("busineCouDollor");
                couponPriceArr.push(couponPrice);
                platformBuisneCouponId.push(couponId);
                couponId = null;
                jsonStoreCoupon = null;
                couponGoodsSet = null;
                w = null;
            }
        });
    }
    exports.busChooseOptimal = busChooseOptimal;
    // 商家优惠点击选择
    oSubOrdCouponBus.find("li").hammer().on("tap", function() {
        var $parentGoodslist = $(this).parents(".js_carListBox");
        var $parent = $(this).parents(".js_subOrdCouponBus");
        // 优惠劵弹框
        var oCarListBox = $(this).parents(".js_carListBox");
        // 商家的一整块区域
        var oBusConpon = $(this).find(".js_busConpon");
        // 找到对应的优惠券
        var supplierId = parseInt(oCarListBox.find(".js_storeOwner").attr("data-supplierId"));
        //商家的Id
        var nbusniPrice = $(this).find(".js_busniConponPrice").text() * 1;
        // 商家优惠劵价格
        var sLimitPrice = $(this).find(".js_busConponLimit").text() * 1;
        // 商家优惠劵价格
        var index = couponIndex(supplierId);
        // 商家索引
        var totalPrice = $parent.siblings(".js_subPrice").find(".js_calSum").attr("data-calsum") * 1;
        // 这个商家的商品价格总和
        var oBusinessPay = $parent.siblings(".js_useCouponBus").find(".js_businessPay");
        // 优惠劵使用展示信息
        $(this).siblings().find(".js_busConpon").removeClass("active");
        var jsonStoreCoupon = {};
        var couponId, couponGoodsSet, couponPrice;
        if (oBusConpon.hasClass("active")) {
            // 没有选择优惠劵
            oBusConpon.removeClass("active");
            nbusniPrice = 0;
            setPriceText(function() {
                // 获取选择的信息
                platformBuisneCouponId[index] = 0;
                couponPriceArr[index] = 0;
            });
            $parentGoodslist.find(".js_goodsPrice").attr("data-reducePrice", 0);
            coupon.setBusPrice();
        } else {
            // 选择一个优惠劵
            oBusConpon.addClass("active");
            nbusniPrice = $(this).find(".js_busniConponPrice").text();
            couponbusineId = $(this).find(".js_busConpon").attr("couponBuisId");
            setPriceText(function() {
                // 获取选择的信息
                platformBuisneCouponId[index] = couponbusineId;
                couponPriceArr[index] = nbusniPrice;
            });
            if (oBusConpon.attr("data-goodsSet") !== undefined) {
                couponPrice = oBusConpon.find(".js_busniConponPrice").text();
                $parentGoodslist.find(".js_goodsPrice").attr("data-reducePrice", 0);
                // 商家id supplierId,
                // 商家优惠劵 couponId，
                // 指定商品数组 couponGoodsSet，
                // 设置条件 couponLimitType，
                // 优惠劵面值价格 couponPrice
                var _arr = [];
                couponId = oBusConpon.attr("couponBuisId");
                couponGoodsSet = oBusConpon.attr("data-goodsSet").replace(/\s*/g, "").replace("[", "").replace("]", "");
                couponGoodsSet.indexOf(",") > -1 ? _arr = couponGoodsSet.split(",") : _arr.push(couponGoodsSet);
                jsonStoreCoupon = {
                    supplierId: supplierId,
                    couponId: couponId * 1,
                    couponGoodsSet: _arr,
                    couponLimitType: oBusConpon.attr("data-limitType") * 1,
                    couponPrice: couponPrice * 1
                };
                coupon.priceScale(jsonStoreCoupon);
            }
        }
        //设置页面 商家优惠信息
        function setPriceText(fn) {
            if (totalPrice < sLimitPrice) {
                oBusinessPay.text("不使用");
                oBusinessPay.attr("data-businePrice", 0);
                oBusinessPay.addClass("busineCouDollor");
                myPub.TipLayer("此优惠券不可用", "no", function() {}, 2);
                oBusConpon.removeClass("active");
                $parentGoodslist.find(".js_goodsPrice").attr("data-reducePrice", 0);
            } else if (nbusniPrice == 0) {
                oBusinessPay.text("不使用");
                oBusinessPay.attr("data-businePrice", nbusniPrice);
                oBusinessPay.addClass("busineCouDollor");
            } else {
                oBusinessPay.text("-￥" + nbusniPrice);
                oBusinessPay.attr("data-businePrice", nbusniPrice);
                oBusinessPay.removeClass("busineCouDollor");
            }
            if (fn) fn();
        }
        coupon.initCoupons();
        myPub.HamstopPropaga();
    });
    // coupon.CostPrice();
    coupon.initCoupons();
    // 判断商家的下标
    function couponIndex(index) {
        arrbusineArr = [];
        $(".js_storeOwner").each(function() {
            arrbusineArr.push($(this).attr("data-supplierid"));
        });
        for (var i = 0; i < arrbusineArr.length; i++) {
            if (arrbusineArr[i] == index) {
                ide = i;
            }
        }
        return ide;
    }
});
define("static_v4/js/mod/submit_billing", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    $(function() {
        var oBillingType = $(".js_billingType");
        // 发票类型
        var oText = $(".js_Text");
        // 输入框
        var oBillMobile = $(".js_billMobile");
        // 手机输入框
        var oBillMail = $(".js_billMail");
        // 邮箱
        var oBillingHead = $(".js_billingHead");
        // 发票抬头选择
        var oBillingContList = $(".js_billingContList");
        // 普通商品发票内容选择
        var oBillingInfo = $(".js_billingInfo");
        // 收票信息
        var oSubmitApply = $(".js_submitApply");
        // 提交
        var oSubmitCancel = $(".js_submitCancel");
        // 不使用
        var oUseBillSide = $(".js_useBillSide");
        // 提交订单 发票使用入口
        var oBillSide = $(".js_billSide");
        // 发票弹框
        var oShadow = $(".js_shadow");
        // 阴影
        var oBllingText = $(".js_billingText");
        // 发票信息展示
        var $isJifen = $("#isJifen");
        //判断是否是积分商品
        var $oJifen = $(".js_isJifen");
        var $ljkType = $(".ljkType");
        //选中礼品卡
        var bSideOff = true;
        var sType = oUseBillSide.attr("itype");
        // 后台传递发票类型 [0,1],[0],[1], sType 是字符串；
        var moveHeight = oBillSide.outerHeight(true);
        // 发票弹框高度，包含margin ，padding，border；
        var oTips = $(".js_tips");
        // 电子发票提示文字；
        var mobile = $(".js_mobile").val();
        oBillSide.css({
            bottom: -moveHeight
        });
        //是积分商品去掉发票信息
        //是积分商品去掉“发票信息”。我添加多一条件判断，如果发票类型 sType 为 null 或者 长度为 0 ，那直接隐藏发票信息；
        // || !sType || sType == ' ' || sType.length <= 0
        if ($isJifen.val() != "false" || !sType || sType == " " || sType.length <= 0) {
            $oJifen.hide();
        }
        // 如果返回的类型包含有“电子发票”则显示提示文字；
        if (sType && sType.indexOf("1") >= 0) {
            oTips.show();
        }
        function OnlyBillType(sType) {
            var _Li = oBillingType.find("li");
            // 判断禁止发票类型          
            _Li.each(function(i) {
                if (sType.indexOf(_Li.eq(i).attr("billType")) <= 0) {
                    _Li.eq(i).addClass("unactive");
                    _Li.eq(i).attr("style", "display: none;");
                }
                //  如果只有一个发票类型，因为默认选中的是“普通发票”，所以当只有一个发票类型且发票类型为“电子发票”，则默认发票类型改为“电子发票”
                if (sType.indexOf(_Li.eq(i).attr("billType")) >= 0 && sType.length == 3) {
                    oBillingType.find("li").removeClass("active");
                    $(this).addClass("active");
                    if (_Li.eq(i).attr("billType") == "1") {
                        oBillingInfo.show();
                    }
                }
            });
        }
        //验证地址是否选择
        function checkAddress() {
            var address = $("#province").html();
            if (null != address && "" != address) {
                return true;
            } else {
                return false;
            }
        }
        // 发票弹框显示
        oUseBillSide.hammer().on("tap", function() {
            if ($ljkType.hasClass("active")) {
                return;
            }
            if (!checkAddress()) {
                myPub.TipLayer("请您先填写地址信息！");
                return;
            }
            if (!bSideOff) return;
            bSideOff = false;
            OnlyBillType(sType);
            var companyName = $("#companyName").val();
            var taxpayerCode = $("#taxpayerCode").val();
            if (companyName == null || companyName == "" || taxpayerCode == null || taxpayerCode == "") {
                G_JSON_GET(base + "/m/o/1.0/invoiceInfo/get", {
                    mobile: mobile
                }, function(data) {
                    if (data.ret.code == 0) {
                        $("#companyName").val(data.data.companyName);
                        $("#taxpayerCode").val(data.data.taxCode);
                    }
                });
            }
            oBillSide.show().stop().animate({
                bottom: 0
            }, 300, function() {
                oShadow.show();
                bSideOff = true;
            });
            myPub.HamstopPropaga();
        });
        oShadow.hammer().on("tap", function() {
            //隐藏服务
            HideBillSide();
            myPub.HamstopPropaga();
        });
        // 发票弹框关闭
        function HideBillSide(fn) {
            oBillSide.stop().animate({
                bottom: -moveHeight
            }, 300, function() {
                oBillSide.hide();
                oShadow.hide();
                // $('html').removeClass('bodyHeight100');
                bSideOff = true;
                if (fn) fn();
            });
        }
        // 手机号中间隐藏4位数
        if (oBillMobile.find(".js_mobile").length > 0) {
            HideNum(oBillMobile.find(".js_mobile"));
        }
        // 表格显示和隐藏清除按钮
        oText.on("input propertychange", function() {
            var _val = $(this).val();
            var oClearBtn = $(this).siblings(".js_clearBtn");
            _val == "" ? oClearBtn.hide() : oClearBtn.show();
        });
        // 手机验证
        oBillMobile.find("input").on("input propertychange", function() {
            var _val = $(this).val();
            if (checkPhoneNumber(_val)) {
                oBillMobile.removeClass("has_error").addClass("has_success");
            } else {
                oBillMobile.addClass("has_error").removeClass("has_success");
            }
        });
        //邮箱
        oBillMail.find("input").on("input propertychange", function() {
            var _val = $(this).val();
            if (checkMail(_val)) {
                oBillMail.removeClass("has_error").addClass("has_success");
            } else {
                oBillMail.addClass("has_error").removeClass("has_success");
            }
        });
        // 发票类型选择
        oBillingType.find("li").hammer().on("tap", function() {
            // 判断是否是禁止的
            if ($(this).hasClass("unactive")) return;
            oBillingType.find("li").removeClass("active");
            $(this).addClass("active");
            if ($(this).attr("billType") == "0") {
                oBillingInfo.hide();
            } else {
                oBillingInfo.show();
            }
        });
        // 抬头发票 个人和公司 选择
        oBillingHead.find("li").hammer().on("tap", function() {
            oBillingHead.find("li").removeClass("active");
            $(this).addClass("active");
            if ($(this).attr("billHead") == "company") {
                oBillingHead.find(".js_companyBill").show();
                return;
            }
            oBillingHead.find(".js_companyBill").hide();
        });
        // 发票内容 选择
        oBillingContList.find("li").hammer().on("tap", function() {
            oBillingContList.find("li").removeClass("active");
            $(this).addClass("active");
        });
        function submitInvoiceInfo(mobile, companyName, taxCode) {
            G_JSON_POST(base + "/m/o/1.0/invoiceInfo/modify", {
                mobile: mobile,
                companyName: companyName,
                taxCode: taxCode
            }, function(date) {});
        }
        // 提交
        oSubmitApply.hammer().on("tap", function() {
            // 发票类型的属性
            var _oBillType = oBillingType.find("li.active").attr("billType");
            var itype = $(".js_billingType li.active").attr("value");
            //发票类型信息
            var ihead = $(".js_billingHead li.active").attr("value");
            //发票抬头信息
            var icontent = $(".js_billingContList li.active").children("span:eq(1)").html();
            var companyName = $("#companyName").val();
            var taxCode = $("#taxpayerCode").val();
            var imobile = $("#billMobile").val();
            if (imobile.indexOf("*") > 0) {
                imobile = mobile;
            }
            var iemail = $("#billElectron").val();
            // 普通发票
            if (_oBillType == "0") {
                checkBillHead(function() {
                    checkContentNull(function() {
                        HideBillSide();
                        oBllingText.text("个人普通发票");
                        var invoice = {
                            itype: parseInt(itype),
                            ihead: parseInt(ihead),
                            icontent: icontent
                        };
                        $("#invoice").val(JSON.stringify(invoice));
                    });
                }, function() {
                    checkCompanyInfo(function() {
                        checkContentNull(function() {
                            HideBillSide();
                            oBllingText.text("公司普通发票");
                            var invoice = {
                                itype: parseInt(itype),
                                ihead: parseInt(ihead),
                                icontent: icontent,
                                companyName: companyName,
                                taxCode: taxCode
                            };
                            submitInvoiceInfo(imobile, companyName, taxCode);
                            $("#invoice").val(JSON.stringify(invoice));
                        });
                    });
                });
            } else if (_oBillType == "1") {
                // 电子发票
                checkBillHead(function() {
                    checkContentNull(function() {
                        checkMobileNull(function() {
                            HideBillSide();
                            oBllingText.text("个人电子发票");
                            var invoice = {
                                itype: parseInt(itype),
                                ihead: parseInt(ihead),
                                icontent: icontent,
                                imobile: imobile,
                                iemail: iemail
                            };
                            $("#invoice").val(JSON.stringify(invoice));
                        });
                    });
                }, function() {
                    checkCompanyInfo(function() {
                        checkContentNull(function() {
                            checkMobileNull(function() {
                                HideBillSide();
                                oBllingText.text("公司电子发票");
                                var invoice = {
                                    itype: parseInt(itype),
                                    ihead: parseInt(ihead),
                                    icontent: icontent,
                                    companyName: companyName,
                                    taxCode: taxCode,
                                    imobile: imobile,
                                    iemail: iemail
                                };
                                submitInvoiceInfo(imobile, companyName, taxCode);
                                $("#invoice").val(JSON.stringify(invoice));
                            });
                        });
                    });
                });
            }
        });
        // 不使用发票
        oSubmitCancel.hammer().on("tap", function() {
            HideBillSide();
            $("#invoice").val("");
            oBllingText.html("添加发票信息");
        });
        // 检测发票抬头类型是 公司还是个人
        function checkBillHead(argPerson, argCompany) {
            // 发票抬头类型
            var _oBillHead = oBillingHead.find("li.active").attr("billHead");
            if (_oBillHead == null || _oBillHead == "") {
                myPub.TipLayer("请选择发票抬头！");
            }
            if (_oBillHead == "person") {
                if (argPerson) argPerson();
            } else if (_oBillHead == "company") {
                if (argCompany) argCompany();
            }
        }
        //检测发票内容
        function checkContentNull(fn) {
            var content = $(".js_billingContList li.active").children("span:eq(1)").html();
            if (content == null || content == "") {
                myPub.TipLayer("请选择发票内容！");
            } else {
                if (fn) fn();
            }
        }
        // 检测发票抬头公司信息  输入框是否为空
        function checkCompanyInfo(fn) {
            var _oCompanyBillInput = oBillingHead.find(".js_companyBill input");
            if (_oCompanyBillInput.eq(0).val() == "") {
                myPub.TipLayer("请输入您的公司名称！");
            } else if (_oCompanyBillInput.eq(1).val() == "") {
                myPub.TipLayer("请输入纳税人识别码！");
            } else {
                if (fn) fn();
            }
        }
        // 检测收票输入框是否为空
        function checkMobileNull(fn) {
            var _mobile = oBillMobile.find("input").val();
            var _email = oBillMail.find("input").val();
            if (_mobile == "") {
                myPub.TipLayer("请输入您的手机号码！");
            } else if (!checkPhoneNumber(_mobile)) {
                myPub.TipLayer("请输入正确的手机号码！");
            } else if (_email == "") {
                myPub.TipLayer("请输入您的邮箱！");
            } else if (!checkMail(_email) && _email != "") {
                myPub.TipLayer("请输入正确的邮箱！");
            } else {
                if (fn) fn();
            }
        }
        // 校验电话号码
        function checkPhoneNumber(v) {
            var regMobile = /^1[2|3|4|5|6|7|8|9]\d{9}$/;
            //验证手机号码
            var regPhone = /^(^0\d{2}-?\d{8}$)|(^0\d{3}-?\d{7}$)|(^\(0\d{2}\)-?\d{8}$)|(^\(0\d{3}\)-?\d{7}$)$/;
            //验证固定电话
            if (regMobile.test(v) || regPhone.test(v) || HidePhone(mobile) == v) {
                return true;
            }
            return false;
        }
    });
    // 校验邮箱
    function checkMail(v) {
        var regMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,29})+$/;
        if (regMail.test(v)) {
            return true;
        }
        return false;
    }
    // 隐藏手机中间4位
    function HideNum(obj) {
        var phone = obj.val();
        var mphone = phone.substr(3, 4);
        var lphone = phone.replace(mphone, "****");
        obj.attr("value", lphone);
    }
    function HidePhone(phone) {
        var mphone = phone.substr(3, 4);
        var lphone = phone.replace(mphone, "****");
        return lphone;
    }
});
define("static_v4/js/mod/submit_orderGlobal_sea", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    var oWrap = $(".js_wrap");
    var oGlobalSubmit = $(".js_globalSubmit");
    // 保存按钮
    var oGlobalTxt = $(".js_globalTxt");
    // 输入框
    var oidtxt = $(".js_txt");
    // 保存后身份证号的内容
    var oidIput = $(".js_iDinput");
    // 输入身份证内容
    var osaveId = $(".js_savedId");
    // 保存后身份证号内容
    var name = $('input[name="shipName"]').val();
    //身份证名字，收货人姓名
    var oIdNo = $("input[name='idCardNo']");
    //身份证号码提交
    var oIDCard = $(".js_iDCard");
    // 身份认证框
    var oGlobalTip = $(".js_iDCard_globalTip");
    // 提示内容
    var oGlobal_chioce = $(".js_global_chioce");
    // 全球购协议
    var oPayment = $(".js_btnPay");
    // 去付款按钮
    var oGlobalchange = $(".js_globalchange");
    // 修改验证框里边内容
    var oClearBtn = $(".js_clearBtn");
    // 清空输入框内容
    var obuyknowDetail = $(".js_buykonw_detail");
    // 购买须知按钮
    var oPhotoBox = $(".js_photoBox");
    // 检测是否上传图片
    var oActiveCheckBox = $(".js_activeCheckBox");
    // 红色单选框的是否选中状态
    var oIdExplain = $(".js_IdExplain");
    // 上传身份证图片须知
    var Testing = false;
    // 校验按钮是否可点击
    var offTap = true;
    // 防止多次点击
    var moreTapOffTime = null;
    // 多次点击定时器
    var maxLength = 18;
    // 输入框内最大长度
    var IDCardImg = "";
    //身份证照片地址
    var oPhotoListLi = $(".js_photoList");
    var oNoShowImg = $(".js_noShowImg");
    var iszhiyou = $("input[name='iszhiyou']").val();
    var oIdCardNo = idCardNo;
    // 身份证号码
    var oFirontImage = firontImage;
    // 身份证正面照路径
    var oBackImage = backImage;
    // 身份证反面照路径
    var oRightImg = $(".js_rightImg");
    // 身份证图片删除按钮
    var oView = $(".js_view");
    // 显示身份证区域
    var oUpLoadTip = $(".js_upLoadTip");
    // 上传身份证图片提示区域
    // var oIdCardInput = $('#idCardNoHid');               // 身份证号码上传到后台的输入框
    var oPreview = $(".js_preview");
    // 身份证预览
    var oBCIdentifyBtn = $(".js_BCClearBtn");
    // 去完成按钮
    var isBinding = "";
    // 是否绑定
    // BC清关只能立即购买进入的确认订单页面才会有
    if (oBCIdentifyBtn && oBCIdentifyBtn.length > 0) {
        isBinding = binding;
    }
    // 点击去完成按钮
    oBCIdentifyBtn.on("click", function(object) {
        if (isBinding && isBinding == "true") {
            myPub.TipLayerEnd("您还没有绑定手机号码，请绑定", "no", function() {
                if (typeof backHref != "undefined") {
                    window.location.href = "/h/login/bindMobile?backHref=" + backHref;
                } else {
                    window.location.href = "/h/login/bindMobile";
                }
            }, 3);
        } else {
            window.location.href = "/myInfo/toIdentification?backHref=" + backHref;
        }
    });
    // 检测是否是全球购商品 在检测是否绑定手机号
    if (oIDCard.length > 0) {
        if (typeof bindMobile != "undefined" && bindMobile == "bindMobile") {
            // 没有绑定的话 弹出 绑定手机弹框
            if (typeof backHref != "undefined") {
                window.location.href = "/h/login/bindMobile?backHref=" + backHref;
            } else {
                window.location.href = "/h/login/bindMobile";
            }
            return;
        }
    }
    var iDTip = [ "为保障顺利清关，请确保收货人姓名和身份证信息保持一致", "格式不符合规定" ];
    if (iszhiyou == 1) {
        iDTip = [ "为保障您的货物顺利清关，请确保收货人姓名和身份证号以及正反面图片真实有效", "格式不符合规定" ];
    }
    var saveId = false;
    // 判断是否保存的按钮；
    var iDBgStyle = "background-color:rgba(6,6,6,.6);color:#fff;";
    // 弹框背景样式
    setSize();
    function setSize() {
        var oWrap_W = oWrap.width();
        oPhotoListLi.css({
            height: oWrap_W * .284,
            width: oWrap_W * .448
        });
    }
    //加密
    var encrypt = function Encrypt(word) {
        var strInfo = "0102030405060708";
        var key = CryptoJS.enc.Utf8.parse(strInfo);
        var iv = CryptoJS.enc.Utf8.parse(strInfo);
        var srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC
        });
        return encrypted.toString();
    };
    // 身份证之前储存过选中地址就显示  身份证号码
    if (oIdCardNo && oIdCardNo != undefined && oIdCardNo != "") {
        oidIput.hide();
        osaveId.show();
        oGlobalTxt.attr("disabled", true);
        oNoShowImg.hide();
        hideNum(oIdCardNo, oidtxt);
        oGlobalTxt.val(oIdCardNo);
        oIdNo.val(encrypt(oGlobalTxt.val()));
        saveId = true;
    }
    // 身份证正面照
    if (oFirontImage && oFirontImage != undefined && oFirontImage != "") {
        oUpLoadTip.eq(0).hide();
        oPhotoBox.eq(0).val(oFirontImage);
        oRightImg.eq(0).show();
        oView.eq(0).find("img").attr("src", httpImageUrl + oFirontImage);
        oPreview.eq(0).attr("src", httpImageUrl + oFirontImage);
        oView.eq(0).find("img").css({
            opacity: 1
        });
    }
    // 身份证反面照
    if (oBackImage && oBackImage != undefined && oBackImage != "") {
        oUpLoadTip.eq(1).hide();
        oPhotoBox.eq(1).val(oBackImage);
        oRightImg.eq(1).show();
        oView.eq(1).find("img").attr("src", httpImageUrl + oBackImage);
        oPreview.eq(1).attr("src", httpImageUrl + oBackImage);
        oView.eq(1).find("img").css({
            opacity: 1
        });
    }
    if (oGlobalTxt.attr("disabled") != "disabled") {
        oNoShowImg.show();
    } else {
        oNoShowImg.hide();
    }
    oNoShowImg.on("click", function() {
        myPub.TipLayer("请先填写并保存收货人的身份证信息", iDBgStyle, function() {});
    });
    // 身份证验证
    oGlobalTxt.on("input propertychange", function() {
        // 通过验证输入框内容，修改提示内容
        iDCardNO(oGlobalTxt, function() {
            Testing = false;
            oGlobalTip.html(iDTip[1]);
        }, function() {
            Testing = true;
            oGlobalTip.html(iDTip[0]);
        });
        // 满足条件 保存按钮可点击
        if (oGlobalTxt.val().length === maxLength) {
            Testing ? oGlobalSubmit.addClass("active") : oGlobalSubmit.removeClass("active");
        } else {
            oGlobalSubmit.removeClass("active");
        }
        // 清空按钮显示
        oGlobalTxt.val().length != 0 ? oClearBtn.show() : oClearBtn.hide();
    });
    // 清空按钮操作
    oClearBtn.on("click", function() {
        oGlobalTxt.val("");
        oGlobalSubmit.removeClass("active");
    });
    // 保存操作
    oGlobalSubmit.on("click", function() {
        // 变亮状态
        if ($(this).hasClass("active")) {
            // 防止多次点击
            if (offTap) {
                oGlobalTxt.blur();
                offTap = false;
                // 绑定手机弹框
                if (Testing) {
                    var idCardNo = encrypt(oGlobalTxt.val());
                    G_JSON_GET("/shop/identify", {
                        name: name,
                        idCardNo: idCardNo,
                        addressId: oAddressId
                    }, function(data) {
                        if (data.repsCode == "success") {
                            oIdNo.val(idCardNo);
                            myPub.TipLayerEnd("保存成功", iDBgStyle, function() {
                                oidIput.hide();
                                osaveId.show();
                                oGlobalTxt.attr("disabled", true);
                                oNoShowImg.hide();
                                hideNum(oGlobalTxt.val(), oidtxt);
                                saveId = true;
                            });
                        } else {
                            myPub.TipLayerEnd(data.repsMsg, iDBgStyle, function() {
                                myPub.LayerCloseAll();
                            });
                        }
                    });
                } else {
                    myPub.TipLayerEnd("身份证号不正确，请核对", iDBgStyle, function() {
                        myPub.LayerCloseAll();
                    });
                }
            }
            clearTimeout(moreTapOffTime);
            moreTapOffTime = setTimeout(function() {
                offTap = true;
            }, 500);
        }
    });
    // 点击修改按钮事件
    oGlobalchange.on("click", function() {
        oidIput.show();
        osaveId.hide();
        oGlobalSubmit.removeClass("active");
        oGlobalTxt.val("");
        oClearBtn.hide();
        oGlobalTxt.attr("disabled", false);
        saveId = false;
        oNoShowImg.show();
    });
    /* 身份证号验证*/
    function iDCardNO(obj, fn1, fn2) {
        // var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/g;   // 15或者18位身份验证
        // var reg = /^\d{17}(\d|X|x)$/g;                              // 18位身份验证
        var reg = /(^\d{17}(\d|X|x)$)|(^\d{0,18}$)/g;
        // 0到18位数字或者17位数字加x
        if (!reg.test(obj.val())) {
            if (fn1) fn1();
        } else {
            if (fn2) fn2();
        }
    }
    // 这只身份证隐藏
    function hideNum(val, el) {
        var nfirst = val.slice(0, 4);
        var nend = val.slice(-4);
        el.text(nfirst + "**********" + nend);
    }
    // 协议选中操作
    oActiveCheckBox.on("click", function() {
        var index = oActiveCheckBox.index($(this));
        if ($(this).hasClass("active")) {
            oActiveCheckBox.eq(index).removeClass("active");
        } else {
            oActiveCheckBox.eq(index).addClass("active");
            if ($(this).hasClass("js_global_chioce")) {
                buyKnowLayer();
            }
        }
    });
    // 全球购检测
    function globalBuyCheck() {
        // 验证身份证图片是否上传
        var oExist = false;
        var checkCrossBorderId = document.getElementById("checkCrossBorderId").value;
        //全球购跨境模式 0：非进口；1：海外直邮；2：国内保税仓
        //非进口 不需要校验
        if (checkCrossBorderId == 0) {
            return true;
        }
        if (checkCrossBorderId == 3) {
            if (isBond != null && isBond != "" && oGlobal_chioce.hasClass("active")) {
                return true;
            } else {
                if (isBond == null || isBond == "" || isBond == undefined) {
                    myPub.TipLayer("请先认证身份信息", iDBgStyle, function() {});
                    return false;
                } else if (!oGlobal_chioce.hasClass("active")) {
                    // 提示勾选购买须知按钮
                    chooseTipLayer();
                }
            }
            return false;
        }
        // 海外直邮和国内保税仓需要进行校验
        // cc和cc2.0海外直邮需要校验2张图片是否都上传
        IDCardImg = "";
        //初始化
        if (oPhotoBox.eq(0).val() !== "" && oPhotoBox.eq(1).val() !== "" && oIdExplain.hasClass("active")) {
            IDCardImg += $("#IDCardImg1").val() + ",";
            IDCardImg += $("#IDCardImg2").val();
            $("#idCardImgPath").val(IDCardImg);
            // alert($("#idCardImgPath").val());
            oExist = true;
        }
        // 国内保税仓  设定oExist为true
        if (checkCrossBorderId != 1 && checkCrossBorderId != 4) {
            oExist = true;
        }
        if (oGlobalTxt.attr("disabled") == "disabled" && oGlobal_chioce.hasClass("active") && oExist) {
            // console.log('ok');
            return true;
        } else {
            // 检测身份证号是否保存
            if (oGlobalTxt.attr("disabled") !== "disabled") {
                myPub.TipLayer("请先填写并保存收货人的身份证信息", iDBgStyle, function() {});
                return false;
            } else if (!oExist) {
                if (oPhotoBox.eq(0).val() == "" || oPhotoBox.eq(1).val() == "") {
                    myPub.TipLayer("请上传身份证正反面图片", iDBgStyle, function() {});
                }
                if (!oIdExplain.hasClass("active")) {
                    myPub.TipLayer("请勾选跨境信息仅限于大当家平台使用", iDBgStyle, function() {});
                }
                return false;
            } else if (!oGlobal_chioce.hasClass("active")) {
                // 提示勾选购买须知按钮
                chooseTipLayer();
            }
        }
    }
    // 提示要勾选购买须知
    function chooseTipLayer() {
        myPub.askLayer("<i>购买全球购商品须同意《用户购买须知》，确认继续下单？</i>", function() {
            oGlobal_chioce.addClass("active");
            myPub.LayerCloseAll();
            oPayment.click();
            // 地址用户名和身份证号校验
            return true;
        }, function() {
            myPub.LayerCloseAll();
        }, "no", function() {}, [ "同意并下单", "我再想想" ]);
    }
    // 购买须知弹窗
    function buyKnowLayer() {
        G_JSON_GET("/shop/pay/toKnow", {
            name: "用户购买须知"
        }, function(data) {
            myPub.TipBtnLayer('<div class="argreeMentInfo">' + data.content + "</div>", "全球购用户须知", "确定", function() {
                myPub.LayerCloseAll();
            }, function() {
                myPub.LayerCloseAll();
            }, function() {
                $(".layermbox").addClass("buykonw");
            });
        });
    }
    //点击购买须知弹出购买须知内容
    obuyknowDetail.on("click", function() {
        buyKnowLayer();
    });
    exports.globalBuyCheck = globalBuyCheck;
});
define("static_v4/js/mod/submit_fanXian", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    /***************************    购物返现使用     ******************************/
    var oSwitchBtn = $(".js_switchBtn");
    // 滑动按钮
    // 滑动按钮开启关闭
    oSwitchBtn.hammer().on("tap swipe", function() {
        var index = oSwitchBtn.index($(this));
        if ($(this).hasClass("js_fanxian")) {
            ShowFanXian(index);
        }
    });
    // 购物返现
    function ShowFanXian(i) {
        if (!oSwitchBtn.eq(i).hasClass("btn_distable")) {
            if (oSwitchBtn.eq(i).hasClass("btn_active")) {
                // 取消
                oSwitchBtn.eq(i).removeClass("btn_active");
            } else {
                // 选中
                oSwitchBtn.eq(i).addClass("btn_active");
            }
            priceCount.yuePrice();
        }
    }
});
define("static_v4/js/mod/submit_lipinka", [ "./public", "./submit_calcLastPrice", "./submit_pay", "./submit_orderGlobal_sea", "./submit_coupon_business", "./submit_coupon" ], function(require, exports, module) {
    var myPub = require("./public");
    var priceCount = require("./submit_calcLastPrice");
    var myCouBussiness = require("./submit_coupon_business");
    var myCouponList = require("./submit_coupon");
    var oUseLiPinKa = $(".js_isLiPinKa");
    // 发票点击弹出弹框处
    var oUseCouponBus = $(".js_useCouponBus");
    // 商家券点击位置
    var oUseCouponSubOrd = $(".js_useCouponSubOrd");
    // 平台券点击位置
    var oGoodsListBoxCou = $(".js_carListBox").find(".js_busConpon");
    // 商家券
    var oCouponList = $(".js_couponList").find(".js_coupon");
    // 平台券
    var oBusinessPay = $(".js_businessPay");
    // 平台优惠券显示处
    var nLpkCanUseNo = $(".js_lpkCost").attr("data-maxcostmoney") * 1;
    // 后台传的礼品卡可用的金额
    /***************************    礼品卡使用说明使用     ******************************/
    var oSwitchBtn = $(".js_switchBtn");
    // 滑动按钮
    var oLpkBtn = $(".js_lpkBtn");
    // 礼品卡按钮
    // 滑动按钮开启关闭
    oSwitchBtn.hammer().on("tap swipe", function() {
        var index = oSwitchBtn.index($(this));
        if ($(this).hasClass("js_lpkBtn")) {
            // 模拟数据模拟用户并没有设置密码
            var isPsd = true;
            if (!isPsd) {
                if (index === 1) {
                    myPub.askLayer("亲，您还没有设置礼品卡的密码哦~", function() {
                        window.location.href = "";
                    }, function() {
                        index = 0;
                        ShowFanXian(index);
                        myPub.LayerCloseAll();
                    }, "no", function() {}, [ "去设置", "暂不设置" ]);
                }
            } else {
                ShowFanXian();
            }
        }
    });
    ShowFanXian(0);
    // 购物返现
    function ShowFanXian() {
        if (!oLpkBtn.hasClass("btn_distable")) {
            if (oLpkBtn.hasClass("btn_active")) {
                // 取消
                oLpkBtn.removeClass("btn_active");
                myCouBussiness.busChooseOptimal();
                // 选中商家券最优
                myCouBussiness.coupon.initCoupons();
                // 使用平台券
                // 商家券使用
                oUseCouponBus.show();
                // 平台券使用
                oUseCouponSubOrd.show();
                // 发票可以用
                oUseLiPinKa.find(".js_hiddenBill").hide();
                oUseLiPinKa.find(".js_billingText").removeClass("color_gray_8F");
                oUseLiPinKa.find(".js_billingText").text("添加发票信息");
                // oUseLiPinKa.find('.js_addInvoiceMess').html(invoiceHtml());
                // 取消唤起支付礼品卡密码
                $('input[name="prepaidCard"]').val(false);
                priceCount.isLpkUse(false);
                $(".js_lpkDeduction").hide();
            } else {
                if (nLpkCanUseNo > 0) {
                    // 选中
                    oLpkBtn.addClass("btn_active");
                    // 取消选中优惠券
                    couUnActive();
                    // 商家券隐藏
                    oUseCouponBus.hide();
                    oBusinessPay.attr("data-businePrice", 0);
                    priceCount.useBuisneCouponPrice(0, 0);
                    // 平台券隐藏
                    oUseCouponSubOrd.hide();
                    myCouponList.initCoupon();
                    priceCount.useCouponPrice(parseFloat(0), 0);
                    oUseCouponSubOrd.find(".js_showPrice").text("0");
                    // 发票不可用
                    oUseLiPinKa.find(".js_hiddenBill").show();
                    oUseLiPinKa.find(".js_billingText").addClass("color_gray_8F");
                    oUseLiPinKa.find(".js_billingText").text("使用礼品卡支付时暂不支持开发票");
                    // oUseLiPinKa.find('.js_addInvoiceMess').html('<span class="color_gray_8F ">使用礼品卡支付时暂不支持开发票</span>');
                    // 清空发票
                    $("#invoice").val("");
                    // 唤起支付礼品卡密码
                    $('input[name="prepaidCard"]').val(true);
                    priceCount.isLpkUse(true);
                    $(".js_lpkDeduction").show();
                }
            }
            priceCount.lpkPrice();
        }
    }
    // 优惠券取消选中  boolean
    function couUnActive() {
        if (oGoodsListBoxCou && oGoodsListBoxCou.length > 0) {
            for (var i = 0; i < oGoodsListBoxCou.length; i++) {
                oGoodsListBoxCou.eq(i).removeClass("active");
            }
        }
        if (oCouponList && oCouponList.length > 0) {
            for (var j = 0; j < oCouponList.length; j++) {
                oCouponList.eq(j).removeClass("active");
                oCouponList.eq(j).removeClass("js_showBusCoup");
            }
        }
    }
});
define("static_v4/js/mod/submit_calcLastPrice", [ "./public", "./submit_pay", "./submit_orderGlobal_sea" ], function(require, exports, module) {
    var myPub = require("./public");
    var payPub = require("./submit_pay");
    var globalBuySea = require("./submit_orderGlobal_sea");
    //引入身份验证js
    //var buniessConpon = require('./submit_coupon_business'); //引入商家优惠券
    var $iTotalPrice = $(".js_totalPrice");
    //产品总价格
    var $iFinalPayPrice = $(".js_finalPayPrice");
    //产品最终支付价格
    var $totalDisCountPrice = $(".js_totalDiscountPrice");
    var $chooseAddress = $(".js_userAddr");
    // 选择地址
    var $chosePayType = $(".js_myPayType");
    // 支付方式
    var $submitBtn = $(".js_btnPay");
    // 提交支付按钮
    var $orderForm = $("#orderForm");
    // 需要支付的表单
    // 校验礼品卡的地方
    var oInputMoney = $(".js_inputMoney");
    //输入框
    var oUseMoneytxt = $(".js_useMoneytxt");
    //最终金额显示位置
    var $memberPointCost = $(".jsMemberPointCost");
    // 积分抵扣区域
    var oSwitchBtn = $(".js_switchBtn");
    // 滑动按钮框
    var $sfMember = $(".jsSFMember");
    // 顺丰会员
    var oiDCard = $(".js_iDCard");
    // 身份证信息节点
    var $sellerList = $(".js_carListBox");
    //所有的卖家
    var oyueCost = $(".js_yueCost");
    // 余额
    var olpkCost = $(".js_lpkCost");
    // 礼品卡
    var ofanXianBtn = $(".js_fanxian");
    // 购物返现
    var oUseCouponBus = $(".js_useCouponBus");
    // 优惠券
    var oLpkBtn = $(".js_lpkBtn");
    var $isJifen = $("#isJifen");
    //判断是否是积分商品
    var $canBuy = $("#canBuy");
    //判断是否可以购买会员积分
    var buyProductList = [];
    // 所有商品
    var subtotalList = [];
    // 所有商品小计价格
    var oAddrBoxShow = $(".js_addrBoxShow");
    // 顶部地址栏
    var oFooterAddress = $(".js_footerAddress");
    // 底部地址栏
    var oTaxFinal = $(".js_taxFinal");
    // 商品税费
    var oFreight = $(".js_freight");
    // 运费标签
    var oCalSum = $(".js_calSum");
    var totalPrice = 0;
    var total = 0;
    var platformCouponPrice = 0;
    var sfMemberCutPrice = 0;
    var memberPointPrice = 0;
    var yuePriceFinal = 0;
    var lpkFinal = 0;
    var useGiftPrice = 0;
    var finalPrice = 0;
    var allTotalPrice = 0;
    var platformBuisneCouponPrice = [];
    //商家优惠券使用的金额
    var platformBuisneCouponId = [];
    // 商家优惠券的Id
    var busnieCouArr = [];
    var nGoodsList = [];
    // 所有商品类型
    var nTaxPrice = 0;
    // 商品税费
    var nFreight = 0;
    // 总运费
    var platformCouponId = 0;
    var $texRi = $(".addInvoiceMess > .texRi");
    var oBllingText = $(".js_billingText");
    // 发票信息展示
    if (oFreight && oFreight.length > 0) {
        nFreight = oFreight.attr("data-freight") * 1;
    }
    //如果是积分商品且不满足购买条件，对提交按钮置灰且不可点击
    if ($isJifen.val() && $canBuy.val() == "false") {
        //将按钮置灰
        $submitBtn.find("button").removeClass("btn_Bgred").addClass("btn_Bggray");
    }
    // 如果商品有税费
    if (oTaxFinal && oTaxFinal.length > 0) {
        // BC税费商品只能从立即购买进入确认订单页，所以页面上只能有一个商品，也有一个数量
        nTaxPrice = oTaxFinal.text() * 1;
    } else {
        nTaxPrice = 0;
    }
    initAllPrice();
    calcAndShowPrice();
    // 初始化所有价格计算参数
    function initAllPrice() {
        var oAllPrice = {};
        // 储存所有的价格与相应的商家优惠券优惠的金额
        var buniesCon = 0;
        // 商家优惠券的金额
        var buniesConarr = [];
        subtotalList = [];
        nGoodsList = [];
        totalPrice = 0;
        allTotalPrice = 0;
        $sellerList.each(function() {
            var $sellerBox = $(this);
            buyProductList = [];
            var supplierId = parseInt($sellerBox.find(".js_storeOwner").attr("data-supplierId"));
            $sellerBox.find(".js_goodsList li").each(function() {
                var $goodsLi = $(this);
                var $goodsArea = $goodsLi.find(".js_carListArea");
                var goodsId = parseInt($goodsArea.attr("data-goodsId"));
                var productId = parseInt($goodsArea.attr("data-productId"));
                var goodsFinalPrice = parseFloat($goodsArea.find(".js_goodsPrice").attr("data-finalPrice"));
                var quantity = parseInt($goodsArea.find(".js_quantity").attr("data-quantity"));
                var buyProduct = {
                    supplierId: supplierId,
                    goodsId: goodsId,
                    productId: productId,
                    quantity: quantity,
                    price: goodsFinalPrice
                };
                nGoodsList.push(1);
                buyProductList.push(buyProduct);
            });
            // 如果有商家优惠券
            var nIsBusnies = $sellerBox.find(".js_useCouponBus");
            if (nIsBusnies.length > 0) {
                // var maxCostMoney = $sellerBox.find('.js_businessPay ').text();
                var maxCostMoney = $sellerBox.find(".js_businessPay").attr("data-businePrice");
                buniesCon = maxCostMoney;
            } else {
                buniesCon = 0;
            }
            subtotalList.push(buyProductList);
            buniesConarr.push(buniesCon);
        });
        oAllPrice = {
            subtotalList: subtotalList,
            buniesCon: buniesConarr
        };
        for (var j = 0; j < oAllPrice.subtotalList.length; j++) {
            var nCalSum = oAllPrice.subtotalList[j];
            total = 0;
            for (var i = 0; i < oAllPrice.subtotalList[j].length; i++) {
                var totalbranch = nCalSum[i].price * 1 * nCalSum[i].quantity * 1;
                total += totalbranch;
            }
            var nconponBuines = 0;
            if (total < oAllPrice.buniesCon[j]) {
                nconponBuines = 0;
            } else {
                nconponBuines = oAllPrice.buniesCon[j];
            }
            allTotalPrice += total;
            total = Math.round((total * 1 - nconponBuines * 1) * 100) / 100;
            oCalSum.eq(j).text(total);
            totalPrice += total;
        }
        if (totalPrice >= sfMemberCutPrice) {
            totalPrice = totalPrice - sfMemberCutPrice;
        } else {
            sfMemberCutPrice = totalPrice;
            totalPrice = 0;
        }
        return totalPrice;
    }
    exports.initAllPrice = initAllPrice;
    /**
     * 获取最大可以使用的礼品卡金额
     */
    function calAllProduct() {
        var allProductList = [];
        // 所有商品
        $sellerList.each(function() {
            var $sellerBox = $(this);
            var supplierId = parseInt($sellerBox.find(".js_storeOwner").attr("data-supplierId"));
            $sellerBox.find(".js_goodsList li").each(function() {
                var $goodsLi = $(this);
                var $goodsArea = $goodsLi.find(".js_carListArea");
                var goodsId = parseInt($goodsArea.attr("data-goodsId"));
                var productId = parseInt($goodsArea.attr("data-productId"));
                var categoryId = parseInt($goodsArea.attr("data-categoryId"));
                var goodsFinalPrice = parseFloat($goodsArea.find(".js_goodsPrice").attr("data-finalPrice"));
                var quantity = parseInt($goodsArea.find(".js_quantity").attr("data-quantity"));
                var buyProduct = {
                    supplierId: supplierId,
                    goodsId: goodsId,
                    productId: productId,
                    categoryId: categoryId,
                    quantity: quantity,
                    finalPrice: goodsFinalPrice
                };
                allProductList.push(buyProduct);
            });
        });
        return allProductList;
    }
    exports.calAllProduct = calAllProduct;
    initChooseAddress();
    // 初始化选择(切换)地址的事件
    function initChooseAddress() {
        // 绑定选择地址事件
        $chooseAddress.click(function() {
            var memo = getSupplierMemo();
            var eMemo = encodeURI(encodeURI(memo));
            var isGroupBuy = $("#isGroupBuy").val();
            var groupBuyType = $("#groupBuyType").val();
            var groupBuyActivityId = $("#groupBuyActivityId").val();
            var groupBuyRecordId = $("#groupBuyRecordId").val();
            if (sellMemberId != null && sellMemberId != "undefined") {
                window.location.href = "/member/address/chooseAddress?backHref=" + backHref + "&memo=" + eMemo + "&sellMemberId=" + sellMemberId + "&isGroupBuy=" + isGroupBuy + "&groupBuyType=" + groupBuyType + "&groupBuyActivityId=" + groupBuyActivityId + "&groupBuyRecordId=" + groupBuyRecordId;
            } else {
                window.location.href = "/member/address/chooseAddress?backHref=" + backHref + "&memo=" + eMemo + "&isGroupBuy=" + isGroupBuy + "&groupBuyType=" + groupBuyType + "&groupBuyActivityId=" + groupBuyActivityId + "&groupBuyRecordId=" + groupBuyRecordId;
            }
        });
    }
    initMemo();
    // 初始化 买家留言
    function initMemo() {
        // console.log(memoData);
        var json = {};
        var memoDataArray = memoData.split("|");
        for (var idx = 0; idx < memoDataArray.length; idx++) {
            var memoArray = memoDataArray[idx].split(",");
            if (memoArray.length == 2) {
                json[memoArray[0]] = memoArray[1];
            }
        }
        $sellerList.each(function() {
            var $sellerBox = $(this);
            var supplierId = parseInt($sellerBox.find(".js_storeOwner").attr("data-supplierId"));
            var supplierMemo = json[supplierId] ? json[supplierId] : "";
            $sellerBox.find(".js_message").find("input[name='Message']").val(supplierMemo);
        });
    }
    // 买家留言清除按钮
    messageClear();
    function messageClear() {
        $sellerList.each(function(n, el) {
            var oimportMsg = $(el).find(".js_importMsg");
            // 留言输入框
            var oMessageClearBtn = $(el).find(".js_messageClearBtn");
            // 留言清除按钮
            oimportMsg.on("input propertychange", function() {
                if (oimportMsg.val().length > 0) {
                    oMessageClearBtn.show();
                } else {
                    oMessageClearBtn.hide();
                }
            });
            oMessageClearBtn.on("click", function() {
                oimportMsg.val("");
                $(this).hide();
            });
        });
    }
    /*滚动时显示底部地址栏*/
    scrollAdress();
    function scrollAdress() {
        var nAddBoxHeight = oAddrBoxShow.outerHeight(true) + 20;
        // 顶部地址栏的高度
        var nFooterAddress = oFooterAddress.outerHeight(true);
        // 顶部地址栏的高度
        $(window).on("scroll", function() {
            var afterScroll = $(this).scrollTop();
            if (afterScroll > nAddBoxHeight) {
                $(".js_addresPadd").css({
                    "padding-bottom": nFooterAddress + 15 + "px"
                });
                oFooterAddress.show();
            } else {
                oFooterAddress.hide();
                $(".js_addresPadd").css({
                    "padding-bottom": 0
                });
            }
        });
    }
    /**
     * 获取所有的买家留言 json
     */
    function getSupplierMemo() {
        var memoData = [];
        $sellerList.each(function() {
            var $sellerBox = $(this);
            var supplierId = parseInt($sellerBox.find(".js_storeOwner").attr("data-supplierId"));
            var memo = $sellerBox.find(".js_message").find("input[name='Message']").val();
            memoData.push([ supplierId, memo ].join(","));
        });
        return memoData.join("|");
    }
    /**
     * 使用商家优惠券的调用方法
     */
    var nBuniesTotalCoup = 0;
    function useBuisneCouponPrice(couponId, arr) {
        platformBuisneCouponId = couponId;
        busnieCouArr = arr;
        calcAndShowPrice();
    }
    exports.useBuisneCouponPrice = useBuisneCouponPrice;
    /**
     * 使用优惠券的调用方法
     */
    function useCouponPrice(couponPrice, couponId) {
        platformCouponPrice = couponPrice;
        platformCouponId = couponId;
        // console.log("platformPrice %o" ,platformCouponPrice);
        calcAndShowPrice();
    }
    exports.useCouponPrice = useCouponPrice;
    /**
     * 获取最大可以使用的礼品卡金额
     */
    function getMaxGiftPrice() {
        return totalPrice - platformCouponPrice;
    }
    exports.getMaxGiftPrice = getMaxGiftPrice;
    /**
     * 设置支付方式
     */
    function choosePayType(payType) {
        // console.log("payType = %o",payType);
        $orderForm.find('input[name="payType"]').val(payType);
        calcAndShowPrice();
    }
    exports.choosePayType = choosePayType;
    /**
     * 使用礼品卡金额的方法
     */
    function useGiftMoney(giftPrice) {
        useGiftPrice = giftPrice;
        // console.log("useGiftMoney %o" ,giftPrice);
        calcAndShowPrice();
    }
    exports.useGiftMoney = useGiftMoney;
    /**
     * 检查计算礼品卡的金额
     */
    function checkGiftPrice() {
        // console.log("checkGiftPrice %o %o %o",useGiftPrice,totalPrice,platformCouponPrice,nBuniesTotalCoup)  allTotalPrice;
        if (useGiftPrice > allTotalPrice - platformCouponPrice - memberPointPrice - nBuniesTotalCoup) {
            useGiftPrice = allTotalPrice - platformCouponPrice - memberPointPrice - nBuniesTotalCoup;
            oInputMoney.val(useGiftPrice);
            oUseMoneytxt.text("-￥" + useGiftPrice);
        }
    }
    /**
     * 计算最终价格
     */
    function calcAndShowPrice() {
        $iTotalPrice.text(allTotalPrice.toFixed(2));
        // 计算会员积分和价格
        // 计算商家优惠券金额
        // 计算平台优惠券金额
        if (platformCouponId != 0) {
            $orderForm.find('input[name="coupon"]').val(platformCouponId);
        } else {
            $orderForm.find('input[name="coupon"]').val("");
        }
        // 商家优惠券id传入指定位置
        if (platformBuisneCouponId.length !== 0) {
            // platformBuisneCouponId = platformBuisneCouponId.join(',');
            $orderForm.find('input[name="businesCoupon"]').val(platformBuisneCouponId);
        } else {
            $orderForm.find('input[name="businesCoupon"]').val("");
        }
        // 计算商家优惠券的优惠总金额
        if (busnieCouArr.length !== 0) {
            nBuniesTotalCoup = 0;
            for (var i = 0; i < busnieCouArr.length; i++) {
                nBuniesTotalCoup += busnieCouArr[i] * 1;
            }
        } else {
            nBuniesTotalCoup = 0;
        }
        // 使用余额抵扣
        yuePriceCost();
        // 使用礼金卡
        lpkCost();
        // 计算会员积分抵扣
        calcMemberPoint();
        // 计算礼品卡使用金额
        // 计算一下顺丰会员价格
        calcSFMemberPoint();
        // 校验礼品卡使用金额
        checkGiftPrice();
        $orderForm.find('input[name="deposit"]').val(useGiftPrice.toFixed(2));
        var regionId = "";
        if ($('input[ name = "regionId" ]').length > 0) {
            regionId = $('input[name="regionId"]').val();
        }
        $totalDisCountPrice.text((platformCouponPrice + useGiftPrice + sfMemberCutPrice + nBuniesTotalCoup).toFixed(2));
        finalPrice = totalPrice - platformCouponPrice - memberPointPrice - useGiftPrice - yuePriceFinal - lpkFinal + nTaxPrice + nFreight;
        if ($orderForm.find('input[name="payType"]').val() == "GIFTCODE" || $orderForm.find('input[name="payType"]').val() == "DELIVERYCODE") {
            finalPrice = 0;
        }
        //若最终金额为0.01，则不能使用余额抵扣，将按钮置灰
        if (finalPrice == .01 * nGoodsList.length && !ofanXianBtn.hasClass("btn_active")) {
            ofanXianBtn.addClass("btn_distable");
            ofanXianBtn.removeClass("btn_active");
        } else {
            ofanXianBtn.removeClass("btn_distable");
        }
        $iFinalPayPrice.text(finalPrice.toFixed(2));
        transLpk();
    }
    /**
     * 使用余额的方法
     */
    function yuePrice() {
        calcAndShowPrice();
    }
    exports.yuePrice = yuePrice;
    function yuePriceCost() {
        initAllPrice();
        if (oyueCost.length > 0) {
            var maxCostMoney = oyueCost.attr("data-maxCostMoney");
            //使用余额抵扣，需要支付至少0.01
            var nowCanUseMoney = Math.min((totalPrice - platformCouponPrice - .01 * nGoodsList.length).toFixed(2), maxCostMoney);
            if (ofanXianBtn.hasClass("btn_active")) {
                yuePriceFinal = nowCanUseMoney;
                $orderForm.find('input[name="isUseBalance"]').val(true);
            } else {
                yuePriceFinal = 0;
                $orderForm.find('input[name="isUseBalance"]').val(false);
            }
            if (yuePriceFinal == 0) {
                ofanXianBtn.removeClass("btn_active");
                $orderForm.find('input[name="isUseBalance"]').val(false);
            }
            $orderForm.find('input[name="balanceAmount"]').val(yuePriceFinal);
        }
    }
    /**
     * 使用礼品卡的方法
     */
    function lpkPrice() {
        calcAndShowPrice();
    }
    exports.lpkPrice = lpkPrice;
    function lpkCost() {
        if (olpkCost.length > 0) {
            var maxCostMoney = olpkCost.attr("data-maxCostMoney");
            var nowCanUseMoney = Math.min(Number(totalPrice - platformCouponPrice), maxCostMoney);
            if (oLpkBtn.hasClass("btn_active")) {
                lpkFinal = nowCanUseMoney;
            } else {
                lpkFinal = 0;
            }
            if (lpkFinal == 0) {
                oLpkBtn.removeClass("btn_active");
            }
        }
        $(".js_lpkDeductionNo").text(lpkFinal);
        $orderForm.find('input[name="cardBalanceAmount"]').val(lpkFinal);
    }
    /**
     * 校验礼品卡
     */
    function transLpk() {
        var payType = $orderForm.find('input[name="payType"]').val();
        var hasGray = $(".js_myPayType").find(".ljkType").hasClass("gray");
        if ("PREPAIDCARDCODE" == payType) {
            $(".giftCard").hide();
            var salePrice = $(".js_finalPayPrice").html();
            G_JSON_POST("/shop/pay/showPrepaidCardPay", {
                salePrice: salePrice
            }, function(data) {
                if (!data) {
                    myPub.TipLayer("礼品卡余额不足", "no");
                    $chosePayType.siblings().find(".js_checkBox").removeClass("active");
                    $chosePayType.eq(0).find(".js_checkBox").addClass("active");
                    $orderForm.find('input[name="payType"]').val($chosePayType.eq(0).attr("data-payType"));
                    $(".js_myPayType").find(".ljkType").addClass("gray");
                    $(".giftCard").show();
                } else {
                    $("#orderForm").eq(0).find("input[name='prepaidCard']").val("true");
                    $("#invoice").val("");
                    $texRi.hide();
                    oBllingText.addClass("noInvoiceSupport");
                    oBllingText.html("礼品卡购物暂不支持开发票");
                }
            });
        } else {
            $(".giftCard").show();
            if (hasGray) {
                $(".js_myPayType").find(".ljkType").removeClass("gray");
            }
        }
    }
    function calcMemberPoint() {
        initAllPrice();
        if ($memberPointCost.length > 0) {
            var costRate = parseInt($memberPointCost.attr("data-CostRate"));
            var maxCostMoney = parseInt($memberPointCost.attr("data-maxCostMoney"));
            var nowCanUseMoney = Math.min(parseInt(totalPrice - platformCouponPrice), maxCostMoney);
            if (nowCanUseMoney <= 0) {
                nowCanUseMoney = 0;
            }
            var nowCostPoint = nowCanUseMoney * costRate;
            $memberPointCost.find(".jsPointCost").html(nowCostPoint);
            $memberPointCost.find(".jsPointCostMoney").html(nowCanUseMoney);
            if (oSwitchBtn.hasClass("btn_active")) {
                memberPointPrice = nowCanUseMoney;
                $orderForm.find('input[name="isUsePoint"]').val(true);
            } else {
                memberPointPrice = 0;
                $orderForm.find('input[name="isUsePoint"]').val(false);
            }
        }
    }
    /**
     * 使用会员积分的方法
     */
    function useMemberPoint() {
        calcAndShowPrice();
    }
    exports.useMemberPoint = useMemberPoint;
    /**
     * 使用顺丰会员积分的方法
     */
    function calcSFMemberPoint() {
        if ($sfMember.length > 0) {
            var cutPrice = parseFloat($sfMember.attr("data-cutPrice"));
            if ($sfMember.find(".js_memberBtn").hasClass("btn_active")) {
                sfMemberCutPrice = cutPrice;
            } else {
                sfMemberCutPrice = 0;
            }
        }
        initAllPrice();
    }
    /**
     * 使用顺丰会员积分的方法
     */
    function useSFMemberPoint() {
        calcSFMemberPoint();
    }
    exports.useSFMemberPoint = useSFMemberPoint;
    //提交订单按钮单击事件
    $submitBtn.click(function() {
        // 2018年4月19日lou增加全球购身份验证
        // 关于身份证与购买须知的判断
        if (oiDCard.length === 1) {
            if (!globalBuySea.globalBuyCheck()) {
                // console.log(2222222);
                return false;
            }
        }
        //积分商品判断不可点击
        if ($isJifen.val() && $canBuy.val() == "false") {
            return false;
        }
        // 验证地址是否已选
        if (!checkAddress()) {
            return false;
        }
        // 验证是否是顺丰官微会员
        var useMember = $(".js_memberBtn").hasClass("btn_active");
        if (useMember) {
            $orderForm.find("input[name='sfMemberBuy']").val(1);
        }
        // 赠送他人的验证
        if (!checkIsSongLi()) {
            return false;
        }
        // 鲜花任选 检查
        checkMultiProduct();
        // 备注的设置
        var memoText = getSupplierMemo();
        $orderForm.find("input[name='memos']").val(memoText);
        // 发货时间选择
        $orderForm.find("input[name='userDeliveryTime']").val($("#goodsDeliveryDate").find("li.active").attr("value"));
        //var bljkOff = $('.js_lpkBtn').hasClass('btn_active');  // 判断是否开启礼品卡支付
        // 默认地址弹窗提醒
        if (giftOrder != null && (giftOrder == 1 || giftOrder == 2)) {
            if ($(this).data("repeatclick")) {
                myPub.TipLayer("请勿重复提交");
                return false;
            }
            $(this).data("repeatclick", true);
            // 送礼订单 不需要地址 直接提交订单
            toPay();
        } else if (autoDefault == 1) {
            var _tit = "请核对您的收货地址";
            //#666
            var comfirmMsg = $(".js_userAddr a").html();
            myPub.askLayer(comfirmMsg, function() {
                myPub.LayerCloseAll();
                toPay();
            }, function() {}, _tit);
        } else {
            toPay();
        }
    });
    // 判断礼品卡混合支付是否开启
    var prepaidCard = "";
    function isLpkUse(boolen) {
        if (boolen) {
            prepaidCard = "true";
        } else {
            prepaidCard = "false";
        }
    }
    exports.isLpkUse = isLpkUse;
    /**
     * 提交支付的方法
     */
    function toPay() {
        // userAction();
        if (isGrouperFree == "true") {
            var payUrl = "/shop/nowbuy/groupFreePay";
        } else if (prepaidCard == "true") {
            var payUrl = "/prepaidCard/payFromLpkPay";
        } else {
            var payUrl = "/shop/payment/orderPay";
        }
        var data = $orderForm.serialize();
        payPub.submitPay(payUrl, data);
    }
    // 验证地址
    function checkAddress() {
        // 送礼订单不需要地址
        if (giftOrder != null && (giftOrder == 1 || giftOrder == 2)) {
            $orderForm.find('input[name="giftOrder"]').val(giftOrder);
            return true;
        }
        if ($orderForm.find('input[name="shipMobile"]').val().trim() == "") {
            myPub.TipLayer("请选择收货地址");
            return false;
        }
        return true;
    }
    //检验是否是赠送他人
    function checkIsSongLi() {
        var isSongLiValue = $orderForm.find('input[name="isSongLi"]').val();
        // console.log("isSongLiValue %o",isSongLiValue);
        if (isSongLiValue != "true") {
            $orderForm.find("input[name='buyerName']").val("");
            $orderForm.find("input[name='buyerPhoneNumber']").val("");
            return true;
        }
        var oUserName = $(".js_userName").attr("judgeBloor");
        var oUserIphone = $(".js_userIphone").attr("judgeBloor");
        if (oUserName == "true" && oUserIphone == "true") {
            $orderForm.find("input[name='buyerName']").val($("#songliUsername").val());
            $orderForm.find("input[name='buyerPhoneNumber']").val($("#songliUserPhone").val());
            return true;
        } else if (oUserName == "false") {
            myPub.TipLayer("购买者姓名不符合规则或者为空！");
            return false;
        } else if (oUserIphone == "false") {
            myPub.TipLayer("电话号码不符合规则或者为空！");
            return false;
        }
    }
    // 检查是否是鲜花任选
    function checkMultiProduct() {
        if (typeof xgCount != "undefined" && xgCount > 1 && saleModel == 1) {
            $("input[name='multiProductIds']").val(multiProductIds);
            $("input[name='quantity']").val(1);
        }
    }
    // 添加用户行为
    function userAction() {
        // 添加用户行为
        var _calAllProduct = calAllProduct();
        var setActionData = [];
        var data_requestid = $("input[name=recRequestId]").val();
        var data_goodschannel = $("input[name=goodschannel]").val();
        var data_sceneType = $("input[name=sceneType]").val();
        for (var i = 0; i < _calAllProduct.length; i++) {
            setActionData[i] = {};
            setActionData[i].pid = _calAllProduct[i].productId * 1;
            setActionData[i].num = _calAllProduct[i].quantity * 1;
            setActionData[i].requestid = data_requestid;
            if (data_goodschannel == "datagrand" || data_goodschannel == "not_datagrand") {
                setActionData[i].scenetype = "cate";
            } else {
                setActionData[i].scenetype = data_sceneType;
            }
        }
    }
});
define("static_v4/js/mod/submit_pay", [ "./public" ], function(require, exports, module) {
    var myPub = require("./public");
    // var lpkPay = require('./submit_lpkPay');
    var $orderForm = $("#orderForm");
    // 需要支付的表单
    var $canBuy = $("#canBuy");
    // 判断是否可以购买积分商品
    var $isJifen = $("#isJifen");
    //判断是否是积分商品
    var $submitBtn = $(".js_btnPay");
    // 提交支付按钮
    var oFullGroup = $(".js_fullGroup");
    // 拼单已满提示弹窗
    var oCashMain = $(".js_cashMain");
    var oShadows = $(".js_shadowlpk");
    var kcuid = $("#kcuid").val();
    //为爱狂吃活动？？？
    var tempOrderSn;
    var tempOrderType;
    var tempPaymentId;
    //如果是积分商品且不满足购买条件，对提交按钮置灰且不可点击
    /*if($isJifen.val() && $canBuy.val() == 'false'){
        //将按钮置灰
        $submitBtn.find('button').removeClass('btn_Bgred').addClass('btn_Bggray');
    }*/
    function submitPay(payUrl, payData) {
        /*if($isJifen.val() && $canBuy.val() == 'false'){
            //积分商品不满足条件，按钮不可点击
            return;
        }*/
        G_JSON_POST(payUrl, payData, function(data) {
            tempOrderSn = data.one_order_sn;
            tempOrderType = data.order_type;
            tempPaymentId = data.payment_id;
            // 添加标识功能
            myPub.uploadCollection(payUrl, data.one_order_sn, function() {
                if ("PAYFINISH" == data.return_code) {
                    paySuccess();
                    return;
                }
                if ("SUCCESS" != data.return_code) {
                    if ("FULL_FAIL" == data.return_code) {
                        $("#groupBuyRecordId").val("");
                        oFullGroup.show();
                    } else {
                        myPub.TipLayer(data.return_msg);
                    }
                    if (data.resultObject != null) {
                        $('input[name="token"]').val(data.resultObject);
                    }
                    return;
                }
                if ("ALIPAY" == data.pay_type) {
                    if (submitAliPay) {
                        submitAliPay(data.return_from_text);
                    } else {
                        forbiddenPayType("ALIPAY");
                    }
                } else if ("WEIXIN" == data.pay_type) {
                    if (submitWeixinPay) {
                        submitWeixinPay(data.timeStamp, data.nonceStr, data.package, data.signType, data.paySign, paySuccess, payCancel, payFail);
                    } else {
                        forbiddenPayType("WEIXIN");
                    }
                } else if ("GLOBAL_ALIPAY" == data.pay_type) {
                    submitAliPay(data.return_from_text);
                } else if ("WEIXIN_HIPO" == data.pay_type) {
                    //商户号和币种  这里直接写死。后面调试完毕后，在统一后台返回参数
                    var sessionUid = myPub.getCookie("token");
                    window.location.href = "https://api.wisecashier.com/mp_pay/oauth?merchant_no=" + data.merchantNo + "&currency=" + data.currency + "&sessionUid=" + sessionUid + "&sysTradeNo=" + data.payment_order_sn;
                } else if ("QQQB" == data.pay_type) {
                    if (submitQQQBPay) {
                        submitQQQBPay(data.token_id, paySuccess, payCancel, payFail);
                    } else {
                        forbiddenPayType("QQQB");
                    }
                } else if ("WEIXIN_H5" == data.pay_type) {
                    if (submitWeixinH5) {
                        submitWeixinH5(data.mweb_url);
                    } else {
                        forbiddenPayType("WEIXIN_H5");
                    }
                } else if ("PREPAIDCARDCODE" == data.pay_type) {
                    ljkPay(data.totalFee, data.phone);
                } else if ("H5_ABCBANKPAY" == data.pay_type) {
                    if (submitABCBankPay) {
                        submitABCBankPay(data.return_from_text);
                    } else {
                        forbiddenPayType("H5_ABCBANKPAY");
                    }
                } else {
                    myPub.TipLayer("不存在的支付方式");
                }
            });
        });
    }
    exports.submitPay = submitPay;
    function paySuccess() {
        if (tempOrderType != null && (tempOrderType == "GIFT" || tempOrderType == "MULTIGIFT")) {
            myPub.locationHref("/shop/gift/sharePage/" + tempPaymentId);
            return;
        }
        var isGroupBuy = $orderForm.find('input[name="isGroupBuy"]').val();
        if ("yes" == isGroupBuy) {
            G_JSON_POST("/GroupBuying/getOrderInfo", "orderSn=" + tempOrderSn, function(data) {
                var recordId = data.recordId;
                if (typeof recordId != "undefined") {
                    // window.location.href = "/h/tuangou/groupOrderDetail/" + recordId;
                    myPub.locationHref("/h/tuangou/groupOrderDetail/" + recordId);
                }
            });
        } else {
            var _orderSn_kcuid = "";
            if (kcuid) {
                // window.location.href = "/member/order/tradeSuccess?orderSn=" + tempOrderSn+"&kcuid="+kcuid;
                _orderSn_kcuid = "?orderSn=" + tempOrderSn + "&payId=" + tempPaymentId + "&kcuid=" + kcuid;
            } else {
                _orderSn_kcuid = "?orderSn=" + tempOrderSn + "&payId=" + tempPaymentId;
            }
            // myPub.locationHref("/member/order/tradeSuccess" + _orderSn_kcuid);
            myPub.locationHref("/h/goodspay/paymentOver" + _orderSn_kcuid);
        }
    }
    function payFail() {
        // TipLayer(res.errMsg);
        localStorage.setItem("orderNav_index", 1);
        window.location.href = "/shop/pay/order_list";
    }
    function payCancel() {
        // TipLayer(res.errMsg);
        localStorage.setItem("orderNav_index", 1);
        window.location.href = "/shop/pay/order_list";
    }
    function forbiddenPayType(type) {
        myPub.TipLayerLong("暂不支持更换支付方式,请从订单下单渠道继续支付或重新下单");
    }
    function ljkPay(totalFee, phone) {
        $(".sxcashCardArea_sum").text("￥" + totalFee);
        $("#gfcUserPhone").val(phone);
        // $('#paymentId').val(paymentId)
        // $('#tempOrderSn').val(tempOrderSn);
        // $('#tempOrderType').val(tempOrderType);
        // lpkPay.ljkPsdShow();
        ljkPsdShow();
        myPub.HamstopPropaga();
    }
    function ljkPsdShow() {
        oCashMain.show().stop().animate({
            bottom: 0
        }, 300, function() {
            oShadows.show();
        });
        myPub.HamstopPropaga();
    }
});
define("static_v4/js/mod/submit_lpkPay", [ "./public", "./submit_pay" ], function(require, exports, module) {
    var myPub = require("./public");
    var payPub = require("./submit_pay");
    var $orderForm = $("#orderForm");
    // 需要支付的表单
    // 礼金卡支付密码
    var oCashMain = $(".js_cashMain");
    // 礼金卡弹出区域
    var oSxcashCardArea = $(".js_sxcashCardArea_input");
    // 礼金卡密码支付的点击区域
    var oPsdEntry = $(".js_psdEntry");
    // 礼金卡密码的input框
    var oPsdAreaDiv = $(".js_psdArea div");
    // 礼金卡的显示区域
    var oPsdAreaTip = $(".js_sxcashCardArea_Tip");
    // 礼金卡的输入提示
    var oShadows = $(".js_shadowlpk");
    var oCloseBtn = $(".js_closeBtn");
    var paymentId = $("#paymentId");
    var tempOrderSn = $("#tempOrderSn");
    var tempOrderType = $("#tempOrderType");
    var gfcUserPhone = $("#gfcUserPhone");
    var nCashPsdIndex = 0;
    // 输入的长度
    var kcuid = $("#kcuid").val();
    //为爱狂吃活动？？？
    var psdScrollTap_timer = null;
    // 失去焦点页面滚动定时器
    //加密
    var encrypt = function Encrypt(word) {
        var strInfo = "0102030405060708";
        var key = CryptoJS.enc.Utf8.parse(strInfo);
        var iv = CryptoJS.enc.Utf8.parse(strInfo);
        var srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, {
            iv: iv,
            mode: CryptoJS.mode.CBC
        });
        return encrypted.toString();
    };
    oSxcashCardArea.on("click", function() {
        oPsdEntry.focus();
        oPsdAreaDiv.eq(nCashPsdIndex).html("<em></em>");
    });
    oPsdEntry.on("input propertychange", function() {
        oPsdAreaDiv.html("");
        nCashPsdIndex = oPsdEntry.val().length;
        for (var i = 0; i < oPsdEntry.val().length; i++) {
            oPsdAreaDiv.eq(i).html("<i></i>");
            oPsdAreaDiv.eq(i + 1).html("<em></em>");
        }
        if (oPsdEntry.val().length == 0) {
            oPsdAreaTip.text("");
            oPsdAreaDiv.eq(0).html("<em></em>");
        } else if (oPsdEntry.val().length == 6) {
            submitLjkPay();
        }
    });
    oPsdEntry.on("blur", function() {
        clearTimeout(psdScrollTap_timer);
        psdScrollTap_timer = setTimeout(function() {
            window.scrollTo(0, document.documentElement.clientHeight);
        }, 100);
        if (nCashPsdIndex == 0) {
            oPsdAreaDiv.eq(0).html("");
        } else {
            oPsdAreaDiv.eq(nCashPsdIndex).html("");
        }
    });
    var cashHeight = oCashMain.outerHeight(true);
    oCashMain.css({
        bottom: -cashHeight
    });
    // 礼金卡显示
    /* function ljkPsdShow() {
        oCashMain.show().stop().animate({ 'bottom':0 },300,function() {
            oShadows.show();
        });
        myPub.HamstopPropaga();
    }
    exports.ljkPsdShow = ljkPsdShow;*/
    // 礼金卡关闭按钮
    oCloseBtn.on("click", function(e) {
        oCashMain.stop().animate({
            bottom: -cashHeight
        }, 300, function() {
            oCashMain.hide();
            oShadows.hide();
            payCancel();
        });
        myPub.HamstopPropaga();
    });
    // 礼金卡点击阴影关闭按钮
    oShadows.on("click", function() {
        oCashMain.stop().animate({
            bottom: -cashHeight
        }, 300, function() {
            oCashMain.hide();
            oShadows.hide();
            payCancel();
        });
    });
    // 如果密码错误则失去焦点清空密码
    function deleteCode() {
        oPsdEntry.val("");
        oPsdAreaDiv.html("");
        nCashPsdIndex = 0;
        oPsdEntry.blur();
    }
    function submitLjkPay() {
        var gfcPayPassword = encrypt(oPsdEntry.val());
        G_JSON_POST("/prepaidCard/checkPayPassword", {
            phone: gfcUserPhone.val(),
            payPassword: gfcPayPassword
        }, function(data) {
            var code = data.code;
            if (1 === code) {
                oCashMain.stop().animate({
                    bottom: -cashHeight
                }, 1e3, function() {
                    oCashMain.hide();
                    oShadows.hide();
                });
                myPub.HamstopPropaga();
                $orderForm.find('input[name="cardUserPassword"]').val(gfcPayPassword);
                $orderForm.find('input[name="prepaidCard"]').val(true);
                toPay();
            } else {
                deleteCode();
                myPub.TipLayer(data.msg, "no", function() {}, 3);
            }
        });
    }
    /**
     * 提交支付的方法
     */
    function toPay() {
        if (isGrouperFree == "true") {
            var payUrl = "/shop/nowbuy/groupFreePay";
        } else {
            var payUrl = "/shop/payment/orderPay";
        }
        var data = $orderForm.serialize();
        payPub.submitPay(payUrl, data);
    }
    function payCancel() {}
    function paySuccess() {
        if (tempOrderType.val() != null && (tempOrderType.val() == "GIFT" || tempOrderType.val() == "MULTIGIFT")) {
            myPub.locationHref("/shop/gift/sharePage/" + paymentId.val());
        }
        var isGroupBuy = $orderForm.find('input[name="isGroupBuy"]').val();
        if ("yes" == isGroupBuy) {
            G_JSON_POST("/GroupBuying/getOrderInfo", "orderSn=" + tempOrderSn.val(), function(data) {
                var recordId = data.recordId;
                if (typeof recordId != "undefined") {
                    myPub.locationHref("/h/tuangou/groupOrderDetail/" + recordId);
                }
            });
        } else {
            var _orderSn_kcuid = "";
            if (kcuid) {
                _orderSn_kcuid = "?orderSn=" + tempOrderSn.val() + "&payId=" + paymentId + "&kcuid=" + kcuid;
            } else {
                _orderSn_kcuid = "?orderSn=" + tempOrderSn.val() + "&payId=" + paymentId;
            }
            // myPub.locationHref("/member/order/tradeSuccess" + _orderSn_kcuid);
            myPub.locationHref("/h/goodspay/paymentOver" + _orderSn_kcuid);
        }
    }
});
var baseurl = "";

var smallImgArg = "?x-oss-process=style/goods_img_3";

var smallImgArg300 = "?x-oss-process=style/goods_img_2";

var smallImgArg200 = "?x-oss-process=style/goods_img";

function check_support_webp() {
    var isSupportWebp = document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp") == 0;
    return isSupportWebp;
}

if (check_support_webp()) {
    smallImgArg = "?x-oss-process=style/goods_webp_3";
    smallImgArg300 = "?x-oss-process=style/goods_webp_2";
    smallImgArg200 = "?x-oss-process=style/goods_webp";
}

define("static_v4/js/mod/public", [], function(require, exports, module) {
    //yx
    //var httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
    //zs
    //var httpImageUrl="https://sfddj-img-bucket.oss-cn-shenzhen.aliyuncs.com/";
    var httpImageUrl;
    var myDoMain = "";
    if (window.location.host == "m.sfddj.com" || window.location.host == "120.76.47.184" || window.location.host == "120.76.207.85" || window.location.host == "120.76.44.28") {
        // httpImageUrl="https://sfddj-img-bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.sfddj.com/";
        myDoMain = "https://m.sfddj.com";
    } else if (window.location.host == "hdm.sfddj.com") {
        httpImageUrl = "https://img.sfddj.com/";
        myDoMain = "https://hdm.sfddj.com";
    } else if (window.location.host == "itsm.sfddj.com") {
        // httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://itsm.sfddj.com";
    } else if (window.location.host == "shop.fx-sf.com") {
        // httpImageUrl="https://fm95338bucket.oss-cn-shenzhen.aliyuncs.com/";
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://shop.fx-sf.com";
    } else if (window.location.host == "www.shhyxypsx.com") {
        httpImageUrl = "https://img.fx-sf.com/";
        myDoMain = "https://www.shhyxypsx.com";
    } else if (window.location.hostname == "localhost") {
        httpImageUrl = "http://img-dev.sfddj.com/";
        myDoMain = "http://localhost:8082";
    }
    exports.httpImageUrl = httpImageUrl;
    exports.myDoMain = myDoMain;
    //加入购物车的动画
    function AddCarAnimate(_X, _Y, target, sLeft, sTop, offsetDis, callBack) {
        // var _X = e.gesture.center.x;
        // var _Y = e.gesture.center.y;
        var time = null;
        var timeTwo = null;
        target.removeClass("myRotateFast");
        target.css({
            left: _X,
            top: _Y,
            opacity: 1
        });
        clearTimeout(time);
        time = setTimeout(function() {
            target.addClass("myRotateFast").stop().animate({
                left: _X,
                top: _Y - 50,
                opacity: 1
            }, 300, function() {
                target.stop().animate({
                    left: sLeft,
                    top: sTop
                }, 600, function() {
                    target.removeClass("myRotateFast");
                    clearTimeout(timeTwo);
                    timeTwo = setTimeout(function() {
                        target.stop().animate({
                            top: sTop + offsetDis * 2,
                            opacity: 0
                        }, 200, function() {
                            if (callBack) callBack();
                        });
                    }, 200);
                });
            });
        }, 30);
    }
    exports.AddCarAnimate = AddCarAnimate;
    // hammer 冒泡
    function HamstopPropaga() {
        window.event.returnValue = false;
        return false;
    }
    exports.HamstopPropaga = HamstopPropaga;
    //hammer事件
    function HammerEvent(obj) {
        this.obj = obj;
    }
    HammerEvent.prototype.addHamEvent = function(obj, type, fn) {
        this.obj = new Hammer.Manager(obj);
        this.obj.add(new Hammer.Pan({
            velocity: 0,
            threshold: 120,
            direction: Hammer.DIRECTION_ALL
        }));
        //平滑
        this.obj.add(new Hammer.Swipe({
            threshold: 8,
            direction: Hammer.DIRECTION_ALL
        }));
        this.obj.add(new Hammer.Tap({}));
        this.obj.add(new Hammer.Press({
            velocity: .6,
            threshold: 8
        }));
        //长时间下压
        this.obj.off(type);
        this.obj.on(type, function(e) {
            if (fn) fn(e);
        });
    };
    exports.HammerEvent = HammerEvent;
    /* 数字验证 */
    function ValiNum(obj, fn1, fn2) {
        var reg = new RegExp("^[0-9]*$");
        if (!reg.test(obj.val())) {
            if (fn1) fn1();
        } else if (obj.val() <= 0) {
            // TipLayer("数量不能小余1");
            obj.val(1);
        } else {
            if (fn2) fn2();
        }
    }
    exports.ValiNum = ValiNum;
    /* 字数统计 */
    function statInputNum(textArea, numItem) {
        var max = [];
        var curLength = [];
        textArea.each(function(i) {
            max[i] = parseInt(numItem.eq(i).text());
            if (textArea.eq(i).val().length > 0) {
                curLength[i] = textArea.eq(i).val().length;
                numItem.eq(i).empty().text(max[i] - curLength[i]);
            }
            textArea.eq(i).attr("maxlength", max[i]).on("input propertychange", function() {
                curLength[i] = $(this).val().length;
                numItem.eq(i).empty().text(max[i] - curLength[i]);
            });
        });
    }
    exports.statInputNum = statInputNum;
    /* 购物车价格统计 */
    function ShopSumPrice(obj, tarFather, target, sumPrice) {
        var _price = 0;
        obj.each(function(i) {
            if (obj.eq(i).hasClass("active")) {
                var _oGoodsPrice = obj.eq(i).parents(tarFather).find(target);
                _oGoodsPrice.each(function(i) {
                    _price += _oGoodsPrice.eq(i).text() * 1;
                    return _price;
                });
            }
        });
        sumPrice.text(_price.toFixed(2));
    }
    exports.ShopSumPrice = ShopSumPrice;
    /*************** 弹框效果 s***************/
    //提示框
    function TipLayer(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shadeClose: false,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayer = TipLayer;
    //提示框_没有遮罩层
    function TipLayer_noShade(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shade: false,
            shadeClose: false,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayer_noShade = TipLayer_noShade;
    //框消失后执行回调提示框
    function TipLayerEnd(sCont, sStyle, fn, T) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            time: T || 2,
            shadeClose: false,
            end: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerEnd = TipLayerEnd;
    // 用户手动关闭弹框
    function TipLayerLong(sCont, sStyle) {
        layer.open({
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            shadeClose: true
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerLong = TipLayerLong;
    // 用户手动关闭弹框有关闭按钮
    function TipLayerLongClose(sTit, sCont, sStyle, fn) {
        layer.open({
            title: sTit != "no" ? sTit : "",
            content: sCont,
            style: sStyle != "no" ? sStyle : "background-color:rgba(255,255,255,1); color:#252525; border:none; border-radius: 5px;",
            scrollbar: false,
            shadeClose: true,
            closeBtn: 1,
            success: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipLayerLongClose = TipLayerLongClose;
    //带按钮提示框
    function TipBtnLayer(sCont, sTit, btnName, yesFn, cancelFn, fn) {
        layer.open({
            title: sTit != "no" ? sTit : "",
            content: sCont,
            btn: btnName == undefined ? [ "确定" ] : [ btnName ],
            shadeClose: false,
            scrollbar: false,
            yes: function() {
                if (yesFn) yesFn();
                LayerCloseAll();
            },
            cancel: function() {
                if (cancelFn) cancelFn();
            },
            success: function() {
                if (fn) fn();
                $(".layermbtn span").css({
                    width: "100%"
                });
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipBtnLayer = TipBtnLayer;
    // 标题提示框
    function TipTitleLayer(sTitle, styleTit, sCont, fn) {
        layer.open({
            title: [ sTitle, "background-color:#fff; color:#666; font-weight:bold" ],
            content: sCont,
            shadeClose: false,
            scrollbar: false,
            style: styleTit,
            cancel: function() {
                if (fn) fn();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.TipTitleLayer = TipTitleLayer;
    //询问层
    function askLayer(sCont, yesFn, noFn, sTit, callBack, aBtnName) {
        layer.open({
            //no 为没有标题 sTit为设置标题
            title: sTit != "no" ? sTit : "",
            content: sCont,
            btn: aBtnName == undefined ? [ "确认", "取消" ] : aBtnName,
            shadeClose: false,
            scrollbar: false,
            yes: yesFn,
            no: noFn,
            cancel: noFn,
            success: function() {
                if (callBack) callBack();
            }
        });
        NoTouchMove($(".laymshade"));
    }
    exports.askLayer = askLayer;
    // 关闭所有弹框
    function LayerCloseAll() {
        layer.closeAll();
    }
    exports.LayerCloseAll = LayerCloseAll;
    //加载层
    function loadLayer(cont) {
        layer.open({
            type: 2,
            content: cont,
            shadeClose: false
        });
        NoTouchMove($(".laymshade"));
    }
    exports.loadLayer = loadLayer;
    //防止滑动
    function NoTouchMove(obj) {
        obj.on("touchmove", function() {
            return false;
        });
    }
    exports.NoTouchMove = NoTouchMove;
    /*************** 弹框效果 e***************/
    //节流控制
    function throttle(method, context, time) {
        time == undefined ? time = 200 : time = time;
        //console.log(time)
        clearTimeout(method.tId);
        method.tId = setTimeout(function() {
            method.call(context);
        }, time);
    }
    exports.throttle = throttle;
    //s20是代表20秒 h是指小时，如12小时则是：h12 d是天数，30天则：d30
    //写cookies setCookie("name","hayden",'s20');
    function setCookie(name, value, time) {
        var strsec;
        if (time == undefined) {
            var Days = 30;
            //默认30天有效期
            strsec = Days * 24 * 60 * 60 * 1e3;
        } else {
            strsec = getsec(time) * 1;
        }
        var exp = new Date();
        exp.setTime(exp.getTime() + strsec);
        document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
    }
    exports.setCookie = setCookie;
    //读取cookies getCookie("name")
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }
    exports.getCookie = getCookie;
    //删除cookies delCookie('name')
    function delCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = getCookie(name);
        if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/";
    }
    exports.delCookie = delCookie;
    //设置cookie时间
    function getsec(str) {
        var str1 = str.substring(1, str.length) * 1;
        var str2 = str.substring(0, 1);
        if (str2 == "s") {
            return str1 * 1e3;
        } else if (str2 == "h") {
            return str1 * 60 * 60 * 1e3;
        } else if (str2 == "d") {
            return str1 * 24 * 60 * 60 * 1e3;
        }
    }
    /* 验证码倒计时 */
    function CutTime(time, fn1, fn2) {
        var _AllTime = time;
        var _T = null;
        clearInterval(_T);
        _T = setInterval(function() {
            if (time <= 0) {
                clearInterval(_T);
                if (fn1) fn1(_AllTime);
            } else {
                time--;
                if (fn2) fn2(time);
            }
        }, 1e3);
    }
    exports.CutTime = CutTime;
    /*手机号码验证*/
    function checkMobile(obj, fn1, fn2, fn3) {
        var oIphone = obj.val();
        var reg = /^(1[1|2|3|4|5|6|7|8|9])[\d]{9}$/;
        //验证手机号码
        if (oIphone == "") {
            if (fn1) fn1();
        } else if (!reg.test(oIphone)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkMobile = checkMobile;
    /*密码验证*/
    function checkPassWord(obj, fn1, fn2, fn3) {
        var _val = obj.val();
        var reg = /^[a-zA-Z0-9]{6,20}$/;
        //6-20位数字和英文
        if (_val == "") {
            if (fn1) fn1();
        } else if (!reg.test(_val)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkPassWord = checkPassWord;
    /*用户名验证*/
    function checkUserName(obj, fn1, fn2, fn3) {
        var _userName = obj.val();
        var reg = /^[A-Za-z\u4e00-\u9fa5][A-Za-z0-9\u4e00-\u9fa5]{1,9}$/;
        //验证用户名
        if (_userName == "") {
            if (fn1) fn1();
        } else if (!reg.test(_userName)) {
            if (fn2) fn2();
        } else {
            if (fn3) fn3();
        }
    }
    exports.checkUserName = checkUserName;
    //图片预加载(window)
    function lazLoadingImgEcho(obj, fn) {
        echo.init({
            container: obj,
            offset: 300,
            throttle: 50,
            //设置图片延迟加载的时间 
            callback: function(element, op) {
                if (fn) fn(element, op);
                // console.log(element, 'has been', op + 'ed')
                var $el = $(element);
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
            }
        });
    }
    exports.lazLoadingImgEcho = lazLoadingImgEcho;
    function lazLoadingImg(obj) {
        this.obj = obj;
    }
    //添加图片预加载
    lazLoadingImg.prototype.AddLazLoadingImg = function(obj, fn) {
        this.obj = echoChangeByCc.initNew({
            container: obj,
            unload: false,
            offset: 300,
            throttle: 80,
            //设置图片延迟加载的时间
            callback: function(element, op) {
                var $el = $(element);
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
                if (fn) fn();
            }
        });
    };
    // 图片预加载 销毁
    lazLoadingImg.prototype.DestroyLazLoadingImg = function() {
        var _this = this.obj;
        if (_this && _this.detach) {
            _this.detach();
        }
    };
    // 图片预加载 刷新
    lazLoadingImg.prototype.RushLazLoadingImg = function() {
        var _this = this.obj;
        _this.render();
    };
    function loadImageCheck(url, callback) {
        //创建一个Image对象，实现图片的预下载
        var img = new Image();
        img.src = url;
        // 如果图片已经存在于浏览器缓存，直接调用回调函数
        if (img.complete) {
            callback();
            img = null;
            return;
        }
        img.onload = function() {
            //图片下载完毕时异步调用callback函数。
            callback();
            img = null;
        };
    }
    exports.lazLoadingImg = lazLoadingImg;
    function lazLoadingImgEchoAbs(obj, fn) {
        echoChangeByCc.initNew({
            container: obj,
            unload: false,
            offset: 200,
            throttle: 30,
            //设置图片延迟加载的时间
            callback: function(element, op) {
                var $el = $(element);
                // console.log($el)
                var sUl = $el.attr("src");
                loadImageCheck(sUl, function() {
                    $el.addClass("fadeIn");
                    $el = null;
                });
                if (fn) fn();
            }
        });
    }
    exports.lazLoadingImgEchoAbs = lazLoadingImgEchoAbs;
    //mui插件事件开关
    function OffMuiEvent(arg) {
        mui.init({
            gestureConfig: {
                tap: arg,
                //默认为true
                swipe: arg
            }
        });
    }
    exports.OffMuiEvent = OffMuiEvent;
    //设置li图片高度 父级获取
    function SetImgHeight(obj, getWidth) {
        var htmlFontSize = $("html").css("font-size");
        var intSize = htmlFontSize.split("p")[0];
        var imgWidth = null;
        if (obj[0].nodeName.toLowerCase() === "li") {
            getWidth ? imgWidth = getWidth / intSize : imgWidth = obj.find("figure").eq(0).parents("a").width() / intSize;
            // obj.find('figure:not(:first)').css({'height': imgWidth+'rem', 'width': imgWidth+'rem'});
            obj.find("figure").css({
                height: imgWidth + "rem",
                width: imgWidth + "rem"
            });
        } else {
            getWidth ? imgWidth = getWidth / intSize : imgWidth = obj.find("li figure").eq(0).parents("a").width() / intSize;
            // obj.find('li figure:not(:first)').css({'height': imgWidth+'rem', 'width': imgWidth+'rem'});
            obj.find("li figure").css({
                height: imgWidth + "rem",
                width: imgWidth + "rem"
            });
        }
    }
    exports.SetImgHeight = SetImgHeight;
    // 日期 2015-09-01 11:16:00
    function FormatDateTime(date, minType, point) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? "0" + m : m;
        var d = date.getDate();
        d = d < 10 ? "0" + d : d;
        var h = date.getHours();
        h = h < 10 ? "0" + h : h;
        var minute = date.getMinutes();
        minute = minute < 10 ? "0" + minute : minute;
        var seconds = date.getSeconds();
        seconds = seconds < 10 ? "0" + seconds : seconds;
        var _sep = "-";
        if (point) _sep = point;
        // 最小到天
        if (minType == "minDay") {
            return y + _sep + m + _sep + d;
        } else if (minType == "minMinute") {
            return y + _sep + m + _sep + d + " " + h + ":" + minute;
        } else {
            return y + _sep + m + _sep + d + " " + h + ":" + minute + ":" + seconds;
        }
    }
    exports.FormatDateTime = FormatDateTime;
    /*************** 滚动条效果 s***************/
    function ScrollBar(obj) {
        this.obj = obj;
    }
    //添加滚动条
    ScrollBar.prototype.AddScroll = function(obj, sOptions) {
        this.obj = new JRoll(obj, sOptions);
    };
    //刷新滚动条
    ScrollBar.prototype.ReScroll = function(fn) {
        var _this = this.obj;
        _this.refresh();
        if (fn) fn();
    };
    //删除滚动条
    ScrollBar.prototype.DelScroll = function(fn) {
        var _this = this.obj;
        _this.destroy();
        if (fn) fn();
    };
    //滚动 到 0
    ScrollBar.prototype.ScrollTo = function(x, y, time, fn) {
        var _this = this.obj;
        _this.scrollTo(x, y, time, false, function() {
            if (fn) fn(_this);
        });
    };
    //滚动开始事件
    ScrollBar.prototype.ScrollStart = function(fn) {
        var _this = this.obj;
        _this.on("scrollStart", fn);
    };
    //滚动结束事件
    ScrollBar.prototype.ScrollEnd = function(fn1, fn2) {
        var _this = this.obj;
        _this.on("scrollEnd", fn1);
        if (fn2) fn2();
    };
    //滚动监听
    ScrollBar.prototype.ScrollIng = function(fn) {
        var _this = this.obj;
        //this.obj.on('scroll', fn);
        this.obj.on("scroll", function() {
            if (fn) fn(_this);
        });
    };
    //滚动下拉刷新
    ScrollBar.prototype.ScrollPullDown = function(sOptions) {
        var _this = this.obj;
        _this.pulldown(sOptions);
    };
    exports.ScrollBar = ScrollBar;
    function getFontSize() {
        var doc = document, win = window;
        var docEl = doc.documentElement, resizeEvt = "orientationchange" in window ? "orientationchange" : "resize", recalc = function() {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            //如果屏幕大于750（750是根据我效果图设置的，具体数值参考效果图），就设置clientWidth=750，防止font-size会超过100px
            if (clientWidth > 750) {
                clientWidth = 750;
            }
            //设置根元素font-size大小
            docEl.style.fontSize = 100 * (clientWidth / 750) + "px";
        };
        //屏幕大小改变，或者横竖屏切换时，触发函数
        win.addEventListener(resizeEvt, recalc, false);
        //文档加载完成时，触发函数
        // doc.addEventListener('DOMContentLoaded', recalc, false);
        $(doc).ready(function() {
            recalc();
        });
    }
    exports.getFontSize = getFontSize;
    function getGoodsNo(url) {
        var reg = new RegExp("^YW[a-zA-Z0-9]{12,14}$");
        var aUrl = "";
        if (!url) return;
        if (url.indexOf("/") > -1) {
            aUrl = url.substr(0).split("/");
            for (var i = 0; i < aUrl.length; i++) {
                if (checkField(aUrl[i])) {
                    return checkField(aUrl[i]);
                } else if (checkField(aUrl[i]) == undefined) {
                    return false;
                }
            }
        } else {
            if (checkField(url)) {
                return checkField(url);
            } else if (checkField(url) == undefined) {
                return false;
            }
        }
        function checkField(_url) {
            var _aUrl = "";
            if (_url.length >= 14) {
                if (_url.indexOf("?") > 0) {
                    _aUrl = _url.split("?");
                    for (var i = 0; i < _aUrl.length; i++) {
                        if (reg.test(_aUrl[i])) {
                            return _aUrl[i];
                        }
                    }
                } else {
                    if (reg.test(_url)) {
                        return _url;
                    } else {
                        return false;
                    }
                }
            } else {
                return false;
            }
        }
    }
    exports.getGoodsNo = getGoodsNo;
    // 检测 安卓 ios 分享 大当家 链接跳转
    function JudgeAppHref(obj, oldH5) {
        var _href = "";
        var _Num = 0;
        var u = navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        // 返回首页操作
        var hrefToHome = [ "/", "sf://" ];
        var hrefName = [ "/h/goodspay/goodsView/", "sf://goodsDetail?goodsSn=" ];
        var sLocationArg = window.location.search.split("?")[1];
        var fxBtn = false;
        if (sLocationArg !== undefined) {
            if (sLocationArg.search("sell_member_id") > -1) {
                fxBtn = true;
            }
        }
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                _Num = 1;
                obj.each(function(i) {
                    _href = obj.eq(i).attr("_href");
                    // 检测回到首页
                    if (_href === "home") {
                        obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                    } else {
                        if (getGoodsNo(_href)) {
                            obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                });
            } else {
                obj.each(function(i) {
                    // 检测回到首页
                    _href = obj.eq(i).attr("_href");
                    if (_href === "home") {
                        AndroidReHome(obj.eq(i));
                    } else {
                        if (getGoodsNo(_href)) {
                            //要去掉a标签自带的href属性，因为这个跳转比点击事件要快，如果有这个属性在安卓上会跳转两次
                            obj.eq(i).removeAttr("href");
                            AndroidGoods(obj.eq(i), getGoodsNo(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                });
            }
        } else if (window.__wxjs_environment === "miniprogram") {
            obj.each(function(i) {
                // 如果有_href 这个自定义属性，_href 只有等于 home 或者 商品编号，就回到小程序页面；
                _href = obj.eq(i).attr("_href");
                if (_href) {
                    // 禁用掉 href
                    // obj.eq(i).attr("href", "javascript:void(0);");
                    obj.eq(i).removeAttr("href");
                    // 检测回到首页
                    if (_href === "home") {
                        minAppEven(obj.eq(i));
                    } else {
                        if (getGoodsNo(_href)) {
                            minAppEven(obj.eq(i), getGoodsNo(_href));
                        } else if (isDrawCouponLink(_href)) {
                            minAppEven(obj.eq(i), false, "/pages/home/drawCoupon/drawCoupon?ruleSign=" + isDrawCouponLink(_href));
                        } else {
                            obj.eq(i).attr("href", _href);
                        }
                    }
                }
            });
        } else if (fxBtn) {
            _Num = 0;
            obj.each(function(i) {
                _href = obj.eq(i).attr("_href");
                if (_href === "home") {
                    obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                } else {
                    if (getGoodsNo(_href)) {
                        obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href) + "?" + sLocationArg);
                    } else {
                        obj.eq(i).attr("href", _href + "?" + sLocationArg);
                    }
                }
            });
        } else {
            _Num = 0;
            obj.each(function(i) {
                _href = obj.eq(i).attr("_href");
                var appendData = _href.indexOf("?") > -1 ? "?" + _href.split("?")[1] : "";
                if (_href === "home") {
                    obj.eq(i).attr("href", hrefToHome[_Num] + _href);
                } else {
                    if (getGoodsNo(_href)) {
                        if (oldH5 === "oldH5") {
                            obj.eq(i).attr("href", "/shop/goods/view/" + getGoodsNo(_href) + appendData);
                        } else {
                            obj.eq(i).attr("href", hrefName[_Num] + getGoodsNo(_href) + appendData);
                        }
                    } else {
                        obj.eq(i).attr("href", _href);
                    }
                }
            });
        }
    }
    exports.JudgeAppHref = JudgeAppHref;
    //判断是否是h5的领券页
    function isDrawCouponLink(url) {
        // var  reg = new RegExp("^YW[a-zA-Z0-9]{12,14}$");
        var ruleSignStr = "";
        if (!url) return false;
        if (url.indexOf("/coupon/drawCoupon") > -1) {
            ruleSignStr = url.split("ruleSign=")[1];
            if (ruleSignStr.indexOf("&") > -1) {
                var ruleSign = ruleSignStr.split("&")[0];
                return ruleSign;
            } else {
                return ruleSignStr;
            }
        } else {
            return false;
        }
    }
    exports.isDrawCouponLink = isDrawCouponLink;
    // 小程序事件处理
    function minAppEven(obj, arg, url) {
        obj.off("click");
        obj.on("click", function() {
            // console.log(arg)
            // 小程序物品详情
            if (arg) {
                wx.miniProgram.navigateTo({
                    url: "/pages/shopping/goodsDetail/goodsDetail?goodsSn=" + arg
                });
            } else if (url) {
                wx.miniProgram.navigateTo({
                    url: url
                });
            } else {
                wx.miniProgram.switchTab({
                    url: "/pages/home/home"
                });
            }
        });
    }
    // 安卓绑定点击事件
    function AndroidGoods(obj, arg) {
        obj.off("click");
        obj.on("click", function() {
            android.goodsDetail(arg);
        });
    }
    // 安卓绑定点击返回首页
    function AndroidReHome(obj) {
        obj.off("click");
        obj.on("click", function() {
            android.toMainAcivity();
        });
    }
    function removeArrayChildren(arr, val) {
        var index = arr.indexOf(val);
        if (index > -1) {
            arr.splice(index, 1);
        }
    }
    exports.removeArrayChildren = removeArrayChildren;
    // 弹框获取焦点后 页面高度调整
    function setFocusBodyScrollTop(timer, fn) {
        var cnt = 0;
        var oBody = $("body");
        timer = setInterval(function() {
            if (cnt < 3) {
                cnt++;
            } else {
                clearInterval(timer);
                timer = null;
                return;
            }
            oBody[0].scrollTop = oBody[0].scrollHeight;
            if (fn) fn();
        }, 300);
    }
    exports.setFocusBodyScrollTop = setFocusBodyScrollTop;
    function locationHref(href) {
        $("body").append($('<a href="' + href + '"><span id="locationHrefId"><span><a>'));
        $("#locationHrefId").click();
    }
    exports.locationHref = locationHref;
    // 检测 安卓 ios 隐藏指定对象
    function JudgeAppHide(ios, and, h5) {
        var u = navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                if (ios) ios();
            } else {
                if (and) and();
            }
        } else {
            if (h5) h5();
        }
    }
    exports.JudgeAppHide = JudgeAppHide;
    function isIphoneXsMinX() {
        return /iphone/gi.test(navigator.userAgent) && screen.height == 812 && screen.width == 375;
    }
    exports.isIphoneXsMinX = isIphoneXsMinX;
    function isIphoneXRXSMax() {
        return /iphone/gi.test(navigator.userAgent) && screen.height == 896 && screen.width == 414;
    }
    exports.isIphoneXRXSMax = isIphoneXRXSMax;
    /**
     * 判断是否是微信浏览器
     * @returns {Boolean}
     */
    function isWeiXin() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == "micromessenger") {
            return true;
        } else {
            return false;
        }
    }
    exports.isWeiXin = isWeiXin;
    /**
     * 判断是否是支付宝浏览器
     * @returns {boolean}
     */
    function isAlipayClient() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/AlipayClient/i) == "alipayclient") {
            return true;
        } else {
            return false;
        }
    }
    exports.isAlipayClient = isAlipayClient;
    /**
     * 判断是否是QQ内置浏览器
     * @returns {boolean}
     */
    function isQQClient() {
        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/QQ/i) == "qq") {
            return true;
        } else {
            return false;
        }
    }
    exports.isQQClient = isQQClient;
    //XSS 前端过滤
    function XssCheck(str, reg) {
        return str ? str.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g, function(a, b) {
            if (b) {
                return a;
            } else {
                return {
                    "<": "&lt;",
                    "&": "&amp;",
                    '"': "&quot;",
                    ">": "&gt;",
                    "'": ""
                }[a];
            }
        }) : "";
    }
    exports.XssCheck = XssCheck;
    /*
    * 判断用户是否安装app,已安装就跳app,未安装就正常跳h5页面
    * 因可能有安卓跳A页面，ios跳B页面的情况，所以两种终端的url分开写
    * androidUrl, iosUrl是跳的指定页面  比如'https://m.sfddj.com/coupon/toCouponCenter'
    * 如果没有指定页面(首页)就不填写或者填写空'' 如isHasApp('','',function(){})或者isHasApp()
    * */
    function isHasApp(androidUrl, iosUrl, fn) {
        var u = navigator.userAgent;
        var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1;
        //android终端或者uc浏览器
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        if (u.search("origin/sfddjapp") == -1) {
            if (isAndroid) {
                // 在安卓的终端
                var HrefUrl = "";
                if (androidUrl && androidUrl != undefined && androidUrl != "") {
                    HrefUrl = "ddjapp://cn.dankal.sf/webpage?url=" + androidUrl;
                } else {
                    HrefUrl = "ddjapp://cn.dankal.sf/android";
                }
                // window.location.href = HrefUrl;
                locationHref(HrefUrl);
                setTimeout(function() {
                    if (fn) fn();
                }, 2e3);
            } else if (isiOS) {
                // 在ios的终端
                var HrefUrl = "";
                if (iosUrl && iosUrl != undefined && iosUrl != "") {
                    HrefUrl = "ddjapk://weburl?url=" + iosUrl;
                } else {
                    HrefUrl = "ddjapk://cn.dankal.sf";
                }
                window.location.href = HrefUrl;
                setTimeout(function() {
                    if (fn) fn();
                }, 2e3);
            }
        } else {}
    }
    exports.isHasApp = isHasApp;
    // 获取链接中的指定参数
    function getSearchString(key) {
        var str = window.location.search;
        str = str.substring(1, str.length);
        // 获取URL中?之后的字符（去掉第一位的问号）
        // 以&分隔字符串，获得类似name=xiaoli这样的元素数组
        var arr = str.split("&");
        var obj = new Object();
        // 将每一个数组元素以=分隔并赋给obj对象
        for (var i = 0; i < arr.length; i++) {
            var tmp_arr = arr[i].split("=");
            obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]);
        }
        return obj[key];
    }
    exports.getSearchString = getSearchString;
    // 跳转支付宝小程序 根据链接后面的 startAliapp 参数跳转
    function gotoMiniAlipay() {
        var _this = this;
        var startAliapp = getSearchString("startAliapp");
        if (!startAliapp) return;
        if (isWeiXin()) return;
        G_JSON_POST("/m/a/jumpLink/1.0/getJumpLink", {
            jumpLinkId: startAliapp
        }, function(data) {
            var _data = data.data;
            var _ret = data.ret;
            if (_ret.code == "0") {
                if (!_data) return;
                var s = document.createElement("a");
                s.href = _data;
                s.click();
            }
        });
    }
    exports.gotoMiniAlipay = gotoMiniAlipay;
    /**
     * 立即下单统计购买数据上传
     * @param order_sn
     * @param callback
     */
    function uploadCollection(payUrl, one_order_sn, callback) {
        // 立即购买的接口才记录
        if (payUrl !== "/shop/payment/orderPay") {
            return callback && typeof callback == "function" && callback();
        }
        var collectData = "/m/o/order/track/1.0/collectData";
        var sign = "";
        var query = window.location.search;
        query = query && query.trim();
        if (query) {
            query = query && query.split("&").filter(function(item) {
                return item.indexOf("goodMk") !== -1;
            });
            if (query && query[0]) {
                // 获取到的标识：F9VAGD597K1IIW0L
                sign = query[0].replace("goodMk=", "");
            }
        }
        if (one_order_sn && sign) {
            G_JSON_POST(collectData, {
                orderSn: one_order_sn,
                sign: sign
            }, function() {
                callback && typeof callback == "function" && callback();
            }, function() {
                callback && typeof callback == "function" && callback();
            });
        } else {
            callback && typeof callback == "function" && callback();
        }
    }
    exports.uploadCollection = uploadCollection;
});
define("static_v4/js/mod/baiduCount", [], function(require, exports, module) {
    var oBody = $("body");
    function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg)) {
            return unescape(arr[2]);
        } else {
            return null;
        }
    }
    function JudgeSource(ios, and, wxmin, wx, alipay, qq, h5) {
        var u = window.navigator.userAgent;
        //var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
        //ios终端
        var isWXMini = window.__wxjs_environment == "miniprogram";
        var ua = u.toLowerCase();
        var isWeiXin = ua.match(/MicroMessenger/i) == "micromessenger";
        var isAlipay = ua.match(/AlipayClient/i) == "alipayclient";
        var isQQ = ua.match(/QQ/i) == "qq";
        // 检测室安卓还是ios
        if (u.search("origin/sfddjapp") > 0) {
            if (isIOS) {
                if (ios) ios();
            } else {
                if (and) and();
            }
        } else if (isWXMini) {
            if (wxmin) wxmin();
        } else {
            if (isWeiXin) {
                if (wx) wx();
            } else if (isAlipay) {
                if (alipay) alipay();
            } else if (isQQ) {
                if (qq) qq();
            } else {
                if (h5) h5();
            }
        }
    }
    // 第三方统计的插件
    var TPLMethods = {
        userInfo: JSON.parse(getCookie("ddj-userInfo")),
        // 百度统计
        baidu: function() {
            /**
             *  百度统计
             */
            var sfddjUrl = "9a6219852c6bc360b517de9714e19810";
            //m.sfddj.com
            (function() {
                var hm = document.createElement("script");
                hm.src = "//hm.baidu.com/hm.js?" + sfddjUrl;
                // var s = document.getElementsByTagName("script")[0];
                // s.parentNode.insertBefore(hm, s);
                oBody.append(hm);
            })();
        },
        // gio 统计
        gio: function() {
            var _this = this;
            !function(e, t, n, g, i) {
                e[i] = e[i] || function() {
                    (e[i].q = e[i].q || []).push(arguments);
                }, n = t.createElement("script");
                // tag = t.getElementsByTagName("script")[0];
                // n.async = 1;
                n.src = ("https:" == document.location.protocol ? "https://" : "http://") + g;
                // tag.parentNode.insertBefore(n, tag)
                oBody.append(n);
            }(window, document, "script", "assets.growingio.com/2.1/gio.js", "gio");
            var _gioSetUserId = "";
            if (_this.userInfo) {
                if (_this.userInfo.memberId) {
                    _gioSetUserId = _this.userInfo.memberId;
                } else if (_this.userInfo.openId) {
                    _gioSetUserId = _this.userInfo.openId;
                } else {
                    _gioSetUserId = "";
                }
            }
            gio("init", "b665fa1721dac33b", {});
            // console.log(ddjhoc.userAction)
            // console.log(gio)
            // 给gio 传递用户信息
            gio("setUserId", _gioSetUserId);
            gio("send");
        }
    };
    // ZaneMa Testing
    $.getScript("/static_v4/js/plug/DDJStatistics.js", function(response, status) {
        ddjhoc.init(function() {
            // TPLMethods.baidu();
            TPLMethods.gio();
        });
    });
});